static variables

 

what happens to static variables when the server is disconnected for more than 2 ticks?

are they remembered? or reset and are reinitialised to their first value?

and... when the server reconnects, do they reinitialise again?

 
Revo Trades:

what happens to static variables when the server is disconnected for more than 2 ticks?

are they remembered? or reset and are reinitialised to their first value?

They are remembered.

 
Revo Trades: what happens to static variables when the server is disconnected for more than 2 ticks?

Nothing. All that happens is you stop receiving ticks.

EAs must be coded to recover.

If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect / Position select loop to recover, or persistent storage (GV+flush or files) of ticket numbers required.

On a network disconnection you might get ERR_NO_RESULT or ERR_TRADE_TIMEOUT. There is nothing to be done, but log the error, return and wait for a reconnection and a new tick. Then reevaluate.