ChartTimePriceToXY() Getting error 4107 in EA when changing timeframes. Loading, loaded recompile works ok.
Error 4107 is ERR_CHART_NOT_FOUND.
When you change timeframe, MT briefly rebuilds the chart and for a short moment the chart context/data is not ready.
During that transition ChartTimePriceToXY() can fail, so you see it only when switching TF while the EA is already attached.
Fix: don’t call it just once in OnInit() . Add a small retry loop with Sleep() and only keep retrying for 4107. Any other error should be treated as a real failure.
This gives the chart time to initialize after the TF switch, preventing the transient 4107 from killing your init.
Error 4107 is ERR_CHART_NOT_FOUND.
When you change timeframe, MT briefly rebuilds the chart and for a short moment the chart context/data is not ready.
During that transition ChartTimePriceToXY() can fail, so you see it only when switching TF while the EA is already attached.
Fix: don’t call it just once in OnInit() . Add a small retry loop with Sleep() and only keep retrying for 4107. Any other error should be treated as a real failure.
This gives the chart time to initialize after the TF switch, preventing the transient 4107 from killing your init.
you are right. thanks for the input.
also found below function very useful.
SeriesInfoInteger(Symbol(),Period(),SERIES_SYNCHRONIZED));
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Gurus any ideas?
If EA is loaded or getting recompiled, no error. If changing tf while EA is loaded, error comes.
ChartTimePriceToXY() failed Error 4107