Hello Friends,

Can you please point me

how to stop EA from trading if the last trade is loss, I want to code this as other EA as the EA i had was compiled EX4.

Extra notes / IDEAS : I had only 1 EA running .

either stop EA from trading or close MT4.

or we can write EA to check the last trade every 5 min, if loss then stop EA or close mt4 .

Will this be possible ?

Sample code i have :

string last;
for(int i=OrdersHistoryTotal()-1,i>=0,i--)
OrderSelect(OrdersHistoryTotal()-1, Select_by_pos,MODE_HISTORY);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
//for buy order
if(OrderType()==OP_BUY && OrderClosePrice()>=OrderTakeProfit()) last="profit";
if(OrderType()==OP_BUY && OrderClosePrice()<=OrderStopLoss()) last="loss";

I think I need to run above code every 5 min and stop other EA if loss . i dont know how to code that .

any other ideas or code is appreciated.

Thanks for Help!!