Hi All,
I'm quite new in coding and have a code that I wanna modify, so any help would be much appreciated.
This code below applies a global SL and TP for all open orders. All I want to make it inactive if the number of open orders is greater than 1. So it should be active if there is only one open order. If the system opens the second order before TP or SL then it should be inactive afterwards.
Is this possible??
cheers,
mem
I'm quite new in coding and have a code that I wanna modify, so any help would be much appreciated.
This code below applies a global SL and TP for all open orders. All I want to make it inactive if the number of open orders is greater than 1. So it should be active if there is only one open order. If the system opens the second order before TP or SL then it should be inactive afterwards.
Inserted Code
if(use_sl_and_tp && total()>1) { double s_l, t_p; for(i=0; i<OrdersTotal(); i++) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || OrderType()>1) continue; type=OrderType(); s_l=OrderStopLoss(); t_p=OrderTakeProfit(); } for(i=OrdersTotal()-1; i>=0; i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || OrderType()>1) continue; if(OrderType()==type) { if(OrderStopLoss()!=s_l || OrderTakeProfit()!=t_p) { OrderModify(OrderTicket(),OrderOpenPrice(),s_l,t_p,0,CLR_NONE); } } } } double profit=0; for(i=0; i<OrdersTotal(); i++) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || OrderType()>1) continue; profit+=OrderProfit(); } if(profit>=tp_in_money || a>0) { closeall(); closeall(); closeall(); a++; if(total()==0) a=0; } if(!stealth_mode && use_sl_and_tp && total()<level) closeall();
Is this possible??
cheers,
mem