My question is when developing an EA in MQL4, what are the best ways to finding the things in your code that are slowing backtesting the most? For example, can I see which lines are causing the CPU the most problem (I know something so literal might not exist, but what about a workaround)?
You can analyse your code using the "Profiler" in MetaEditor. Please refer to help reference in MetaEditor application.
On MT4, MetaEditor is actually a MT5 Editor, so refer to the MT5 online documentation — Code profiling - Developing programs - MetaEditor Help
- www.metatrader5.com
From encountering the same issues in the past, speeding up the backtesting can be done in numerous ways. The one that helped me the most going through some research was to use:
datetime lastBarTime = 0; if (Time[0] != lastBarTime) lastBarTime = Time[0];
Having multiple strategies that run on tick data, there may be some discrepancies with tick versus calling this into your code depending on the timeframe you are back testing. The higher the timeframe the more discrepancies you will see in comparison to the tick version of your EA.
You can analyse your code using the "Profiler" in MetaEditor. Please refer to help reference in MetaEditor application.
On MT4, MetaEditor is actually a MT5 Editor, so refer to the MT5 online documentation — Code profiling - Developing programs - MetaEditor Help
Thanks, I never knew this existed. I think this was what I was looking for
Edit: Do you know why profiling on historical data would be blocked?
Thanks, this should work as well
From encountering the same issues in the past, speeding up the backtesting can be done in numerous ways. The one that helped me the most going through some research was to use:
Having multiple strategies that run on tick data, there may be some discrepancies with tick versus calling this into your code depending on the timeframe you are back testing. The higher the timeframe the more discrepancies you will see in comparison to the tick version of your EA.
I actively do this already, but this is helpful people who don't know
That functionality is only available on MT5. MT4 does not support historical tick data.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
My question is when developing an EA in MQL4, what are the best ways to finding the things in your code that are slowing backtesting the most? For example, can I see which lines are causing the CPU the most problem (I know something so literal might not exist, but what about a workaround)?