molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Thu May 09, 2024 4:28 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Using math intense indicators without bogging down.
PostPosted: Tue Jun 19, 2012 1:31 am 
Offline

Joined: Mon Jun 18, 2012 11:56 pm
Posts: 4
Can anyone help me understand how to create indicators that only update once per new bar? I am running some that have hundreds of calculations in them but can be minute old reference values without much peril.


Top
 Profile  
 
 Post subject: Re: Using math intense indicators without bogging down.
PostPosted: Mon Jun 25, 2012 8:55 am 
Offline
Site Admin

Joined: Fri Oct 16, 2009 3:40 pm
Posts: 451
You cannot use the current bar, or shift 0, or [i]; or you need to use indicators that use the open price only.
To avoid repaint and have the indicator updated only once per bar, try using shift 1 and not 0 ([i+1] in the indicator builder)
The indicators repaint and change values because you tell them to use the current bar that is not formed, so the indicator value changes until the current bar becomes the previous bar


Top
 Profile  
 
 Post subject: Re: Using math intense indicators without bogging down.
PostPosted: Mon Jun 25, 2012 5:20 pm 
Offline

Joined: Mon Jun 18, 2012 11:56 pm
Posts: 4
Repainting or the changing of the value in the current bar is not af any concern to me in the case described. Bandwidth used to recalculate the value every time the price is checked for a trigger event is my concern. I am making thousands of calculations to the point it takes a few seconds to determine my price targets. I want to only do those calculations a single time so I can actually check prices for a trade every few milliseconds rahter than every few seconds.

Also, I want to be able to run more than one instance of the EA in a 5 minute chart. Being disabled for 15 seconds every 5 minutes is tolerable. being disabled for 15 seconds between each price discovery to target entry values is not.

Will shifting an indicator 1 bar make it not recalculate more often than one time per bar, or will it recalculate each time it's value is called?


Top
 Profile  
 
 Post subject: Re: Using math intense indicators without bogging down.
PostPosted: Mon Jun 25, 2012 7:44 pm 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
RidgeRunner wrote:
Help me understand how to create indicators that only update once per new bar...

I want to only do those calculations a single time so I can actually check prices for a trade every few milliseconds...


I don't see how this is possible--to update once per bar, yet check prices for a trade every few milliseconds. Even on a M1 chart, you would be continually checking for new trades using a periodic indicator reading.

RidgeRunner wrote:
Also, I want to be able to run more than one instance of the EA in a 5 minute chart.


Just open duplicate charts. One EA per chart. Same magic numbers if you want inter-EA coordination.

RidgeRunner wrote:
Will shifting an indicator 1 bar make it not recalculate more often than one time per bar, or will it recalculate each time it's value is called?


Yes. For an example, attach the standard MA indi in MT4 and shift it by 1 applied to the Close. The reading will be static as opposed to jumping around.

_________________
I'm not a programmer, but I play one on TV.


Top
 Profile  
 
 Post subject: Re: Using math intense indicators without bogging down.
PostPosted: Tue Jun 26, 2012 8:50 am 
Offline

Joined: Mon Jun 18, 2012 11:56 pm
Posts: 4
RJo wrote:
RidgeRunner wrote:
Help me understand how to create indicators that only update once per new bar...
I want to only do those calculations a single time so I can actually check prices for a trade every few milliseconds...


RJo wrote:
I don't see how this is possible--to update once per bar, yet check prices for a trade every few milliseconds. Even on a M1 chart, you would be continually checking for new trades using a periodic indicator reading.

I would be checking continually against an array of calculated values rather than calculating the values before each check. The values I use will never change after a new bar opens and they are calculated the first time and before the next bar opens.

RidgeRunner wrote:
Also, I want to be able to run more than one instance of the EA in a 5 minute chart.

RJo wrote:
Just open duplicate charts. One EA per chart. Same magic numbers if you want inter-EA coordination.

Perhaps. However, I wonder how doing this will work if both EAs have an identical set of variables but the values of some variables are different.

RidgeRunner wrote:
Will shifting an indicator 1 bar make it not recalculate more often than one time per bar, or will it recalculate each time it's value is called?


RJo wrote:
Yes. For an example, attach the standard MA indi in MT4 and shift it by 1 applied to the Close. The reading will be static as opposed to jumping around.

The fact that the value is constant has nothing to do with whether it is being recalculated 1,000 times each minute. It only shows that the answer did not change. In fact, the example you cite the right end of the MA does jump around. It just does that one bar to the right of the current bar.


Top
 Profile  
 
 Post subject: Re: Using math intense indicators without bogging down.
PostPosted: Tue Jun 26, 2012 9:56 am 
Offline

Joined: Sun Jun 19, 2011 9:38 pm
Posts: 270
"Array of calculated values..."

Ok, I think I get what you mean. It seems you would need a whole bunch of TA blocks in SB in order to analyze your many values. Could get unwieldly in a hurry. I'm imagining an offline database (csv format?) that stores your indicator values and an EA that retrieves them, similarly to how an offline tick chart works. This is well beyond my capability.

"Identical set of variables but the values of some variables are different..."

In SB, you can you change the variable names in one EA. Trade management would remain coordinated using same magic numbers. I'm assuming this creates other problems for your strategy?

"Being recalculated 1,000 times each minute,,,"

Sorry. Bad example by me. Ok... so basically, get rid of the current bar calculation altogether. Maybe, as admin said, hard code open price into the forumulas in your indi's (or use TIB to do it) since there is only one open tick per bar. Or else use Close[1], for example see attached.

For clarification, I think there are 2 different repainting discussions in this thread. There are retroactively repainting indi's, and then there are current bar repainting indi's. All [0] bar calculated indi's do the latter which is what the test[1] indi is aimed at preventing. I believe we are not concerned with retroactive repainting here.


Attachments:
test[1].mq4 [5.35 KiB]
Downloaded 335 times

_________________
I'm not a programmer, but I play one on TV.
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009