- Use the debugger or print out your variables, including _LastError and find out why.
sell_stop_price,3,sell_stop_price + stop_loss_points * .0001
Don't hard code numbers. Code fails on JPY pairs, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
How to manage JPY pairs with parameters? - MQL4 and MetaTrader 4 - MQL4 programming forum-
You buy at the Ask and sell at the Bid.
- Your buy order's TP/SL are triggered when the Bid reaches it. Not the Ask.
-
Your sell order's TP/SL will be triggered when the Ask reaches it. To trigger at
a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 and MetaTrader 4 - MQL4 programming forum - Page 3 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools -> Options {control-O} -> charts -> Show ask line.)
- There are no such functions (iHigh/iLow) in MT5
List of MQL5 Functions - Reference on algorithmic/automated trading language for MetaTrader 5Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
This ea works erratically. It should go active at the 12th hour candle and using the high and low of the 11th candle, the default values. Today, on the USD/CAD it went active at the 13th candle using the high and low of the 12th candle to set the buy and sell stops. Could someone tell why this happened? I have had another incident of this a few days ago without changing the default values.