You must check the result returned by the Copy*** function ( CopyRates and CopyOpen ) . Follow the link and read the documentation.
Add: Since you want to receive data from someone else's timeframe, you really need to study the documentation Organizing Data Access.
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
- www.mql5.com
CopyRates - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Gerardo Calvetty: Hello, I'm new to coding, can you help me solve this code, the EA closes when I change the period to D1 or higher, the error is "array out of range": double open_price = price_open[0]; I use different times for different objects for intraday trading.
You are not checking if CopyOpen is returning enough data or if an error occurred. You are just assuming that it worked and that enough data was copied. Check the value returned by the function.
EDIT: The same applies to CopyRates that Vladimir mentioned above.
Documentation on MQL5: Timeseries and Indicators Access / CopyOpen
- www.mql5.com
CopyOpen - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
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
Hello, I'm new to coding, can you help me solve this code, the EA closes when I change the period to D1 or higher, the error is "array out of range": double open_price = price_open[0]; I use different times for different objects for intraday trading.