Why is sell trailing stop not working !!!!!!!!!!!
When you post code please use the CODE button (Alt-S)!

You correctly wrote: if(Bid-OrderOpenPrice() > TrailingStop*Point) // Break even if(OrderStopLoss() < Bid-TrailingStep*Point) // and higher.
Inverting for selling gives: if(OrderOpenPrice()-Ask > TrailingStop*Point) if(OrderStopLoss() < Ask+TrailingStep*Point)
But you wrote if(OrderOpenPrice()-Ask > TrailingStop*Point) if(OrderStopLoss() > Ask+TrailingStep*Point)
-
Isn't better to write it as:
double newSL= Bid-TrailingStep*Point; if(newSL > MathMax( OrderStopLoss(), OrderOpenPrice() )) // BE and higher. bool zs = OrderModify(OrderTicket(),OrderOpenPrice(),newSL,OrderTakeProfit(),0,clrAliceBlue);
-
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor
You correctly wrote: Inverting for selling gives: But you wrote -
Isn't better to write it as:
-
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor
Thanks a lot it worked finally .. sorry i did not know about that code button
You correctly wrote: Inverting for selling gives: But you wrote -
Isn't better to write it as:
-
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor
void TrailingSell() { for(cnt=OrdersTotal()-1; cnt>=0; cnt--) { if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()) if(OrderMagicNumber()==Magic) if(OrderType()==OP_SELL) if(OrderOpenPrice()-Ask>TrailingStop*Point) if(OrderStopLoss()<Ask+TrailingStep*Point) bool zs = OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStep*Point,OrderTakeProfit(),0,clrAliceBlue); } }
I have modified the code but the trailing do not move more than break even !
please look at photo attached if you know why it do not move more i will be Glad , Thanks Again
<image deleted>I have modified the code but the trailing do not move more than break even !
please look at photo attached if you know why it do not move more i will be Glad , Thanks Again
<image deleted>I have deleted your image as it is not relevant (only showed pending orders).
if(OrderOpenPrice()-Ask>TrailingStop*Point) if(OrderStopLoss()<Ask+TrailingStep*Point)
I don't understand your logic.
Surely it should be
if(OrderOpenPrice()-Ask>=TrailingStop*Point) if(OrderStopLoss()>Ask+TrailingStep*Point)
THAT Function WORK SUCCESSFULY but the SELL TRAILING FUNCTION IS NOT WORKING in the tester !!!!!
CAN ANY ONE HELP ME WHY IT IS NOT WORKING !! PLEASE I AM SO UPSET