How to 'Stop' an EA

 

Hi

Is there a way to stop an EA, like a 'stop' command? I see there is the IsStopped( ) function that looks if it is stopped.

I want my EA to stop or 'switch off' if the last 3 trades have been losers.

The method I plan to use is to put a static bool variable.

Thanks

 
for(int i=orders-1;i>=0;i--) {

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)

{ Print("Error in history!"); break; }

if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;

if(OrderProfit()>0) break;

if(OrderProfit()<0) losses++; }

if(losses>=3) {return(0);}
 

thanks

Thanks - that looks great. It should determine if my last 3 successive trades were all losers. It does not though stop the EA dead in its tracks. - But the code looks very good.

Thanks a million.

 

YES

Thanks - that looks great.

Reason: