Download MetaTrader 5
To add comments, please log in or register
Traders have already contributed more than 300 articles. Write your own one!
Tom
34
Tom 2015.09.16 07:35 

So basically i want switch the enter-conditions if the last trade was a loss.

to check if last trade was a loss i have this code. but i dont know how to proceed.

string last="profit";
for(int i=(OrdersHistoryTotal()-1); i>=0; i--)
 {
   OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);
   if(OrderSymbol()==Symbol())
    {
       //for buy order
       if(OrderType()==OP_BUY && OrderProfit()>0) last="profit";
       if(OrderType()==OP_BUY && OrderProfit()<0) last="loss";
       
       if(OrderType()==OP_BUY && OrderProfit()<0) last="profit";
       if(OrderType()==OP_BUY && OrderProfit()>0) last="loss";
       break; 
    }
 }
/
To add comments, please log in or register