I am not sure what you mean by " When the trailing stop loss reaches 100 pips. Normally, you would add a take profit at 100 pips. Then the order will close.
A trailing stop loss of 100 pips would mean the price would need to increase by 100 pips. When it does, The stop loss would now be at the original "buy" or "sell" price.
It is a simple thing to add a take profit to your order when you open a position.
Here is the page. The sixth element in the position open is the take profit point.
- www.mql5.com
As per Forum rules and recommendations, please edit your post (don't create a new post) and replace your code properly (with "</>" or Alt-S), or attach the original file directly with the "+ Attach file" button below the text box.
NB! Very important! DO NOT create a new post. EDIT your original post.
for(int i=OrdersTotal()-1; i >= 0; i--) { if(OrderSelect(i,SELECT_BY_POS)==True) { if(OrderSymbol()==_Symbol && OrderType()==OP_BUY) { double sl = OrderOpenPrice() - StopOut * _Point; if(OrderStopLoss()>sl) { result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); } } if(OrderSymbol()==_Symbol && OrderType()==OP_SELL) { double sl = OrderOpenPrice() + StopOut * _Point; if(OrderStopLoss()<sl) { result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); } } } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I would like this code to close trades when the trailing stop reaches 100 points.
Can anyone help?