My robot only does correct analysis after a certain time like 30 seconds after starting it. Before that its a mess.
How do I code so that the robot doesnt start working after 30s from starting the bot and not before.
I was thinking using a variable X=TimeCurrent() but it doesnt work inside OnTick() since time is always updating.
Use static or global variables:
int secondsToWait = 30 datetime startTime = 0; int OnInit() { startTime = TimeCurrent(); } void OnTick() { if (TimeCurrent()-startTime<secondsToWait) return; }
Alternatively, consider that most of the times you get into "a mess" because the indicators you use are not ready, so checking BarsCalculated(<indHandle>) may work too.
Use static or global variables:
Alternatively, consider that most of the times you get into "a mess" because the indicators you use are not ready, so checking BarsCalculated(<indHandle>) may work too.
TYVM!!! Have a wonderfull life!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
My robot only does correct analysis after a certain time like 30 seconds after starting it. Before that its a mess.
How do I code so that the robot doesnt start working after 30s from starting the bot and not before.
I was thinking using a variable X=TimeCurrent() but it doesnt work inside OnTick() since time is always updating.