1. Bars() is a function, put parameters in it.
2. There are no default Open/High/Low/Close arrays in MQL5, you have to use CopyHigh() and other functions first to fill them. Or use iHigh() function for a single call.void OnTick() { int bars=Bars(_Symbol, PERIOD_CURRENT); if (bars < 2) { Print("Not enough bars."); return; } int lastIndex = bars - 2; double lastHigh = iHigh(_Symbol, PERIOD_CURRENT, lastIndex); double lastLow = iLow(_Symbol, PERIOD_CURRENT, lastIndex); Print("Last complete bar High: ", lastHigh, " Last Low: ", lastLow); }
Or just use MQL4 compiler :) Rename your file with .mq4 extension.
![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
is it a rare problem or anyone knows how to fix it?
Appreciated for the help!