Looking for the same solution. someone please help
jonathan75:
Hi everyone,
I have already been helped by members of mql5, so I try again with an other problem.
I want to add Trailing stop in my EA but I don't know where I can put the modification without break my code.
For exemple, this is my part of 'Order Close - Buy' :
And I want to add this type of trailing stop (activate for breakeven) :
If someone can help me :)
Thanks in advance
int trailing_stop = 20; double ts; for (int i = OrdersTotal()-1; i >= 0; i --) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { ts = Bid-(Point*trailing_stop); if (OrderStopLoss()=(Point*trailing_stop)) OrderModify(OrderTicket(),OrderOpenPrice(),ts,OrderTakeProfit(),0,White); //-------------->try this<------------------------------------------------- int trailing_stop = 20; double ts; void OnTick() { if(trailing_stop >0) Trail(trailing_stop); return; } void Trail(int _stop)//Put this function at the end of your code { for (int i = OrdersTotal()-1; i >= 0; i --) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { ts = Bid-(Point*_stop); if (OrderStopLoss()=(Point*_stop)) OrderModify(OrderTicket(),OrderOpenPrice(),ts,OrderTakeProfit(),0,White); }
Try my example
The void Trail function you can put at the end of your code and then call it on tick
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
- www.mql5.com
//| Expert initialization function | //| Expert deinitialization function | //| Expert tick function | //| test1 |...
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
Hi everyone,
I have already been helped by members of mql5, so I try again with an other problem.
I want to add Trailing stop in my EA but I don't know where I can put the modification without break my code.
For exemple, this is my part of 'Order Close - Buy' :
And I want to add this type of trailing stop (activate for breakeven) :
If someone can help me :)
Thanks in advance