for(int j=0; j<Total; j++) { bool Select=OrderSelect(j,SELECT_BY_POS,MODE_TRADES); { if(Select>0) { if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) { if(OrderType()==OP_BUY) { if(MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice()>MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop) { if(OrderStopLoss()<MarketInfo(OrderSymbol(),MODE_BID)-MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop) { ticket=OrderModify(OrderTicket(),OrderOpenPrice(),MarketInfo(OrderSymbol(),MODE_BID)- MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop,OrderTakeProfit(),0,Blue); } } } else { if(OrderType()==OP_SELL) { if((OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_ASK))>(MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop)) { if((OrderStopLoss()>(MarketInfo(OrderSymbol(),MODE_ASK)+MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop)) || (OrderStopLoss()==0)) { ticket=OrderModify(OrderTicket(),OrderOpenPrice(),MarketInfo(OrderSymbol(),MODE_ASK)+ MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop,OrderTakeProfit(),0,Red); } } } } } } } } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Dear !
I tried to fix my trailing stop function but i really don't know how to make logic without error "OrderModify error 1".I hope someone can help.
Thank you very much !