EA code to resume trades after shut down.

 

Hi,

Is there any sample code for an EA, that can resume managing the trades after its stopped and then comes back again?

Thanks,
JForex

 
JForex:

Hi,

Is there any sample code for an EA, that can resume managing the trades after its stopped and then comes back again?

Thanks,
JForex

Have it check the Ordermagic number and if it matches you EA's magic number, if there are currently open trades you can then have it check the conditions of the trades, like the protected profits, stop levels etc.

this will prevent it from opening new trades before the previous trades are closed

 
23510 wrote >>

Have it check the Ordermagic number and if it matches you EA's magic number, if there are currently open trades you can then have it check the conditions of the trades, like the protected profits, stop levels etc.

this will prevent it from opening new trades before the previous trades are closed

Thanks.

I was thinking simply write the order ticket number to a file when opening a trade. When EA dies, and then comes back, it reads the file, and checks for these tickets using OrderSelect(ticket,...).

If these tickets are still active, it can start managing these orders as usual.

Does that sound right? If yes, I am looking for a code that does it, or something with similar intent.

Thanks,

JForex.