Hi MQL4 Experts,
I'm trying to code a function that moves my buy order to breakeven after the price moves X amount AGAINST me.
Here'a the code. Can you please point out where I'm going wrong.
Cheers, Tim
if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss,OrderTakeProfit(),0,CLR_NONE))
You are not modifying anything. SL and TP is exactly the same as prior to you trying to modify the order
Thanks for your input Keith,
I'd like to modify the buy order back to the open price. Do I replace TP and SL with OpenOrderPrice()?
Cheers, Tim
Thanks for your input Keith,
I'd like to modify the buy order back to the open price. Do I replace TP and SL with OpenOrderPrice()?
Cheers, Tim
I'm trying to code a function that moves my buy order to breakeven after the price moves X amount AGAINST me.
You would have to modify the TP
if(OrderType()==OP_BUY) if(OrderOpenPrice()-Ask>ATRBESTOP) if(OrderOpenPrice()<OrderStopLoss()) if(!OrderModify(…
-
You buy at the Ask and sell at the Bid. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it.
-
If the market has moved below the OOP, then the OSL has not been hit. It can't possibly be above the OOP.
-
If the market has moved below the OOP, moving to BE would be above the market.
You can't move stops (or pending prices) closer to the market than the minimum: MODE_STOPLEVEL * _Point or SymbolInfoInteger(SYMBOL_TRADE_STOPS_LEVEL).
Requirements and Limitations in Making Trades - Appendixes - MQL4 TutorialOn some ECN type brokers the value might be zero (broker doesn't know.) Use a minimum of two (2) PIPs.
Thanks for your help guys. I've tried the suggested changed but unfortunately, I still can't get it to work. Do you have any other suggestions to try? Cheers, Tim
Wouldn't you want to set break even when your position has moved in plus....never heard of anyone doing the opposite....

- 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 MQL4 Experts,
I'm trying to code a function that moves my buy order to breakeven after the price moves X amount AGAINST me.
Here'a the code. Can you please point out where I'm going wrong.
Cheers, Tim