How to code this simple intention

 

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.

 
palepalepale:

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.

 
Seng Joo Thio:

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!

Reason: