int start() { //---- if (Fun_New_Bar()) { Trailing_Stop(); } //---- return(0); } //+------------------------------------------------------------------+ void Trailing_Stop() { bool TrailingStop = true; int Magic = 00; for(int cnt = OrdersTotal(); cnt >= 0; cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); //---- if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { if(OrderType() == OP_BUY) if(TrailingStop) { // OrderModify(OrderTicket(), OrderOpenPrice(), iLow(NULL,0,1), 0, 0, CLR_NONE); return(0); } if(OrderType() == OP_SELL) if(TrailingStop) { OrderModify(OrderTicket(), OrderOpenPrice(), iHigh(NULL,0,1), 0, 0, CLR_NONE); return(0); } } } } bool Fun_New_Bar() { static datetime New_Time = 0; bool New_Bar = false; if (New_Time!= Time[0]) { New_Time = Time[0]; New_Bar = true; } return(New_Bar); }