Ok.. tried making one myself. This thing didn't work. What went wrong?
Inserted Code
int start()
{
//----
double sell_SL=10 ,buy_SL=0;
int countopenorder=0;
for(int i=0;i<OrdersTotal();i++) {
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
if(OrderType()==OP_BUY && OrderSymbol()==Symbol()) { // manage only opened buy order in a single pair?
countopenorder++;
buy_SL=NormalizeDouble(buy_SL,Digits);
if(OrderStopLoss()> buy_SL) {
buy_SL = OrderStopLoss();
OrderModify(OrderTicket(),OrderOpenPrice(),buy_SL,OrderTakeProfit(),0,CLR_NONE);
}
} else if(OrderType()==OP_SELL && OrderSymbol()==Symbol()) { // manage only opened sell order in a single pair?
countopenorder++;
sell_SL=NormalizeDouble(sell_SL,Digits);
if(OrderStopLoss()<sell_SL) {
sell_SL = OrderStopLoss();
OrderModify(OrderTicket(),OrderOpenPrice(),sell_SL,OrderTakeProfit(),0,CLR_NONE);
}
} else if (countopenorder == 0) { // if no open orders, reset buy & sell SL
buy_SL = 0;
sell_SL = 10;
}
Comment("check buy_SL :", buy_SL, "check sell_SL: ", sell_SL);
}
}
//----
return(0);
}