Download MetaTrader 5

How to stop all EA's from other EA if last trade is loss

To add comments, please log in or register
kon
5
kon  

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 ?

Thanks for Help!!

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";
    } 

}

Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
icemanc:

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 ?

Thanks for Help!!

Search for forum about PostMessageA
To add comments, please log in or register