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.
for(int b=OrdersTotal()-1; b >= 0; b--)
double ATR = NormalizeDouble(iATR(NULL,PERIOD_D1,4,1),5);
double ATRBE = (ATR/3.75)*1.1;
double ATRBESTOP = NormalizeDouble(ATRBE,5);
Print("error modifying sell order ",GetLastError());
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()?
You would have to modify the TP
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 Tutorial
On some ECN type brokers the value might be zero (broker doesn't know.) Use a minimum of two (2) PIPs.
Wouldn't you want to set break even when your position has moved in plus....never heard of anyone doing the opposite....
Please enable the necessary setting in your browser, otherwise you will not be able to log in.