Download MetaTrader 5

Array of ticks in the current bar

To add comments, please log in or register
burrocampeador
75
burrocampeador  

Is there any way to know the list of all ticks in the current bar? My EA lasts a lot of time, so several ticks can appear while my EA is running. Therefore, I need know the list of appeared ticks in the current bar. Is it possible in MQL4?

Thank you very much!

whroeder1
15071
whroeder1  
burrocampeador: My EA lasts a lot of time, so several ticks can appear while my EA is running.
Any ticks that come in while the EA is running are lost.
Ian Venner
2584
Ian Venner  

you would have to make your own array and call RefreshRates() periodically in your long time taking code and each time Bid has changed then it is a new tick

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI  
SDC:

you would have to make your own array and call RefreshRates() periodically in your long time taking code and each time Bid has changed then it is a new tick


Would not the ea becomes busy and ignoring others while it is doing its calculations?
Ian Venner
2584
Ian Venner  
yes unless you interupt the calculations to check for new ticks
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI  
Hmm.. I can see now.
burrocampeador
75
burrocampeador  
Thank you very much for your responses!! Then, the strategy is to program an EA that is a loop and never ends. Inside the loop, the EA saves continuously every tick in an array and sometimes makes the calculations with the mentioned array. Is that correct?
whroeder1
15071
whroeder1  
burrocampeador: Then, the strategy is to program an EA that is a loop and never ends.
The better strategy is to determine when you need to do something (price reaches a trigger) or when the something is no longer valid (new bar), and just return from OnTick() when there is nothing to do.
When OnTick() is called you know it's a new tick. If you loop, you are sampling ticks at your loop frequency, and that may or may not be all ticks.
To add comments, please log in or register