Changing the timeframe or modifying the Expert Advisor causes problems

 

Hello coders,

I recently worked on an Expert Advisor that trades on multiple charts. When I attach the Expert Advisor for the first time to a chart, it works without any issues. However, when I modify the EA inputs or change the timeframe on the chart, the EA stops working. I did some debugging and found that the problem is related to the bar data. After the Expert Advisor goes through OnDeinit() and OnInit() because of a timeframe change, I no longer have any bars available.

Can anyone give me a clue as to why this problem is happening and how I can load data properly in the OnInit() function so that each time I modify the EA, it doesn’t stop working?

 

Welcome to the MQL5 Forum!

Experts here often say:
🚫 "Our crystal balls are broken."

If you want a useful answer, please provide more details (preferably with your code) so others can understand the issue better and help effectively.

NOTE: when posting code - use the CODE button (Alt-S) !