what wrong with trailing stop
Why do this, your function is type void so it does not return a value . . .
if(iTrailingStop < 1)return(-1); // error
Why check this here ? why not check before you call the function . . .
if(iTrailingStop > 0) TrailingStop( OrdersTotal() );
How can this be possible for a BUYSTOP ?
if( Bid - OrderOpenPrice() > Point * iTrailingStop )
Have you ever read and understood this ? : Requirements and Limitations in Making Trades
Your pending Stop trades has become Buy or Sell
the moment
case OP_BUYSTOP:
if Ask-OrderOpenPrice()>= 0 it will become a Buy trade
case OP_SELLSTOP:
if OrderOpenPrice() - Bid >= 0 it will become a Sell trade
i'm try to repair but i hard for me. I can't do it hiccc
price this moment 1.50000
you place a new buystop orderopenprice =Ask+BuyStop*Point; SL=orderopenprice-iStopLoss*Point TP=orderopenprice+iTakeProfit*Point
if(Bid-OrderOpenPrice()>Point*iTrailingStop)
means price above orderopenprice
if that happens you haven't a buystop trade it has become a buy trade !!!!
price this moment 1.50000
you place a new buystop orderopenprice =Ask+BuyStop*Point; SL=orderopenprice-iStopLoss*Point TP=orderopenprice+iTakeProfit*Point
means price above orderopenprice
if that happens you haven't a buystop trade it has become a buy trade !!!!
So now I have to do?
case OP_BUYSTOP:
change it to ???
case OP_BUY:
or is that also hard to understand
void TrailingStop(int iTotal){ int iCount; if(iTrailingStop < 1)return(-1); // error for(iCount=0;iCount<iTotal;iCount++){ OrderSelect(iCount, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol()==Symbol() && OrderMagicNumber() == iMagicNumber) switch(OrderType()){ case OP_BUY: if(Bid-OrderOpenPrice()>Point*iTrailingStop){ if(OrderStopLoss()<Bid-Point*iTrailingStop){ OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*iTrailingStop,OrderTakeProfit(),0,Green); } } break; case OP_SELL: if((OrderOpenPrice()-Ask)>(Point*iTrailingStop)){ if((OrderStopLoss()>(Ask+Point*iTrailingStop)) || (OrderStopLoss()==0)){ OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*iTrailingStop,OrderTakeProfit(),0,Red); } } break; } } return(0);
i change but it not work.
How do you see it does not work ?
i backtest. I have buystop and when buystop become buy, When i have proit so take profit and stoploss it work but trailingstop not work.
i backtest. I have buystop and when buystop become buy, When i have proit so take profit and stoploss it work but trailingstop not work.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use