hello mate
i just wonder why you use in sell orders ask price and bid in buy
and about our question think this is it
void Trail_Stop() { if(Trailing_Stop!=0) { int i=OrdersTotal()-1; for(i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i,SELECT_BY_POS); if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number) { if(OrderType()==OP_BUY) { if( (OrderStopLoss()<OrderOpenPrice() || OrderStopLoss()==0) && Bid-OrderOpenPrice()>=Trailing_Stop*pip*Point && Trailing_Stop*pip>=MarketInfo(Symbol(),MODE_STOPLEVEL) ) OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-Trailing_Stop*pip*Point,Digits),OrderTakeProfit(),0,Gold); } if(OrderType()==OP_SELL) { if( (OrderStopLoss()>OrderOpenPrice() || OrderStopLoss()==0) && OrderOpenPrice()-Ask>=Trailing_Stop*pip*Point && Trailing_Stop*pip>=MarketInfo(Symbol(),MODE_STOPLEVEL) ) OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+Trailing_Stop*pip*Point,Digits),OrderTakeProfit(),0,Gold); } } } } }
Because the stop is calculated from the close price.
and about our question think this is it
Your code will not trail at all, it's a breakeven when Trailing_Stop profit is reached.
Hi,
My ea uses this code for the trailing stop. It is the type of stop that jumps to break even when the trailing stop value is reached and then starts trailing from there.. What do I need to delete (or modify) so that it becomes the type that trails immediately from as soon as the order has been opened?
Thanks in advance!
Forum on trading, automated trading systems and testing trading strategies
If you can't find what you need in the Codebase or the Market, then create a request in Freelance Service.
Because the stop is calculated from the close price.
Your code will not trail at all, it's a breakeven when Trailing_Stop profit is reached.
It does trail from when it jumps to break even.. I am currently using it. I want to adapt it though for a new strategy that trails straight away. This is how I want it to work.. I will try the new code when I'm home so thanks!
hello mate
i just wonder why you use in sell orders ask price and bid in buy
and about our question think this is it
My reply was to Aleksei. His code is not doing what you asked for.
Oh ok, sorry, I was confused. Yes I just found that out whilst testing it. Still stuck at the moment but I'll keep trying
NOT TESTED
void Trail_Stop() { if(Trailing_Stop!=0) { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i,SELECT_BY_POS); if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number) { if(OrderType()==OP_BUY) { if(NormalizeDouble(Bid-Trailing_Stop*pip*Point,Digits)-OrderStopLoss()>Point) OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-Trailing_Stop*pip*Point,Digits),OrderTakeProfit(),0,Gold); } if(OrderType()==OP_SELL) { if(OrderStopLoss()-NormalizeDouble(Ask+Trailing_Stop*pip*Point,Digits)>Point) OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+Trailing_Stop*pip*Point,Digits),OrderTakeProfit(),0,Gold); } } } } }
NOT TESTED

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
My ea uses this code for the trailing stop. It is the type of stop that jumps to break even when the trailing stop value is reached and then starts trailing from there.. What do I need to delete (or modify) so that it becomes the type that trails immediately from as soon as the order has been opened?
Thanks in advance!