Is there a way to have an EA or Indicator's Start function called at a fixed interval, e.g every 1sec ?
DT
Ticks drive EA's not <time> so I dont see how this is possible :(
Even if you make a DLL that somehow watches your PC time, you still are then dependant on a tick arriving to initiate the start()
IMHO, I would plan to go on first tick of <the next bar>
...
if (Volume[0]==1) // first tick of new bar { // Do stuff here }
...
Good Luck
-BB-
Is there a way to have an EA or Indicator's Start function called at a fixed interval, e.g every 1sec ?
I'd like to make decissions right before bar0 closes, but especially at low TFs the ticks are useless for this purpose.
U could use an endless loop to accomplish this:
while (true)
{
//PLACE ALL YOUR MAIN CODE HERE
Sleep(1000); //pause for 1 second
}
It would never end and it wouldn't start the first loop until the first tick came through after init. Then I guess you could check the timecurrent() to see if your bar is about to close.
DT
Ticks drive EA's not <time> so I dont see how this is possible :(
Even if you make a DLL that somehow watches your PC time, you still are then dependant on a tick arriving to initiate the start()
IMHO, I would plan to go on first tick of <the next bar>
...
...
Good Luck
-BB-
I'd be carefull with this:
if (Volume[0]==1)Cause if u have a temporary connection problem or two ticks come in at the same time you'd miss that condition.
U could use an endless loop to accomplish this:
while (true)
{
//PLACE ALL YOUR MAIN CODE HERE
Sleep(1000); //pause for 1 second
}
It would never end and it wouldn't start the first loop until the first tick came through after init. Then I guess you could check the timecurrent() to see if your bar is about to close.
And you'll need to use RefreshRates(); in an infinite loop or you'll get error 129s when placing orders.
Same answer as in your previous request: you have to take into consideration that MT4 time scale is made by ticks (each tick providing you with data), that this scale is different from the usual time scale you seems to refer when you are thinking your strategy (hours, minutes,...), they simply are not sequenced the same way, so it is a contextual logic error to think that way if you do not want to manage a margin error (a time-lag) that will emerge from making a connection between this two clocks (all the anwers above show you this fact).
Think what you want to achieve and then revise your logic according to the precision you want.
Hope it helps.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Is there a way to have an EA or Indicator's Start function called at a fixed interval, e.g every 1sec ?
I'd like to make decissions right before bar0 closes, but especially at low TFs the ticks are useless for this purpose.