MT4 Strategy Tester Returns Zero for Other Timeframes

Report any bugs with the Tickstory Lite software here. Please give as much detail as possible so the issue can be identified and resolved as soon as possible.
Post Reply
Joe1310
Posts: 3
Joined: Wed Sep 27, 2023 7:58 am

MT4 Strategy Tester Returns Zero for Other Timeframes

Post by Joe1310 »

Hello everyone,

I am encountering an issue with the MT4 Strategy Tester when running my Expert Advisor (EA). The problem arises when my EA requests data from timeframes other than the one the tester is running on; it consistently returns a value of zero.

Here's a simplified excerpt from the code that demonstrates the issue:
void OnTick()
{
Print(iClose(NULL, PERIOD_M1, 1));
Print(iClose(NULL, PERIOD_M5, 1));
Print(iClose(NULL, PERIOD_M15, 1));
}

When I run the Strategy Tester on the M1 timeframe, it returns the correct closing price for M1, but returns zero for M5 and M15. The same pattern holds true when testing on other timeframes; it only returns the correct value for the timeframe being tested.

Here are some additional details:

All necessary data has been downloaded and is correctly located in the respective folders:

.fxt files in /tester/history
.hst files in /history/Servername
The tester does not overwrite or redownload data upon starting.

The modeling quality is 99.9% in each test.

MT4 Version: 4.00 build 1380

Tickstory Version: 1.9.7.11 (Build date: 2023-07-05)

I am quite confident that my code is correct, as the issue persists even with this simplified code snippet. Has anyone else experienced this issue, or does anyone have suggestions on how to resolve it?

Thank you in advance for your assistance!

tickstory
Posts: 4899
Joined: Sun Jan 06, 2013 12:27 am

Re: MT4 Strategy Tester Returns Zero for Other Timeframes

Post by tickstory »

Hi Joe1310,

Some points to note:
  • Make sure that you have exported all the FXT time-frames that you intend to back-test with (i.e. M1, M5 & M15 in your code example).
  • The close price for 1 bar back will be zero until those bars are fully formed. So if you are back-testing in M1, you will need to wait until 1 bar is formed, 5 bars for the iClose(null, M5, 1) and 15 bars for the iClose(null, M15, 1).
Hope this helps.

Joe1310
Posts: 3
Joined: Wed Sep 27, 2023 7:58 am

Re: MT4 Strategy Tester Returns Zero for Other Timeframes

Post by Joe1310 »

Hello, and thank you for your response.

I appreciate your suggestions, but I believe there might be some misunderstanding. I have indeed exported all the FXT time-frames that I intend to back-test with, and I am aware of the necessity of having a sufficient number of bars formed before querying data from other time-frames. However, the problem I am facing persists throughout the entire testing period from 2015 to the present, regardless of the ample data available.

To elucidate, here are some examples based on my tests:

When running the test on the M15 timeframe:

iClose(NULL, PERIOD_M1, 1) returns 0
iClose(NULL, PERIOD_M5, 1) returns 0
iClose(NULL, PERIOD_M15, 1) returns the correct value
Conversely, when running the test on the M5 timeframe:

iClose(NULL, PERIOD_M1, 1) returns 0
iClose(NULL, PERIOD_M5, 1) returns the correct value
iClose(NULL, PERIOD_M15, 1) returns 0
These examples demonstrate that only the timeframe being tested returns the correct value, while all other timeframes return zero, regardless of the length of the testing period or the availability of data. The modelling quality is consistently at 99.9% for each timeframe tested, indicating that the data is indeed correctly formatted and located.

I am at a loss for what may be causing this issue, and any further insights or suggestions would be highly appreciated.

Thank you once again for your time and assistance.

tickstory
Posts: 4899
Joined: Sun Jan 06, 2013 12:27 am

Re: MT4 Strategy Tester Returns Zero for Other Timeframes

Post by tickstory »

Hi Joe1310,

We've tried to replicate your setup from what you have told us. We've exported data from 2015 and then tried the code you mentioned:

Code: Select all

Print("M1 :",iClose(NULL, PERIOD_M1, 1));
Print("M5: ",iClose(NULL, PERIOD_M5, 1));
Print("M15:",iClose(NULL, PERIOD_M15, 1));
which results in the following being printed to the Journal (after all bars have fully formed):

2023.09.29 21:02:44.633 2015.01.01 23:44:13 Test1 GBPUSD,M1: M15:1.5569
2023.09.29 21:02:44.633 2015.01.01 23:44:13 Test1 GBPUSD,M1: M5: 1.557
2023.09.29 21:02:44.633 2015.01.01 23:44:13 Test1 GBPUSD,M1: M1 :1.55712

The only time when we were able to replicate your issue is when we hadn't exported the M5 and M15 time-frames. If this isn't the case for you, then all we can suggest is maybe try a smaller dataset (say 3 months) to see if that makes any difference (maybe even try a different MT4 installation just to rule it out?). Outside of that, I think this might be something best answered in the MQL forums as we don't have visibility on why the function would not be working in your case.

Hope this helps.

Joe1310
Posts: 3
Joined: Wed Sep 27, 2023 7:58 am

Re: MT4 Strategy Tester Returns Zero for Other Timeframes

Post by Joe1310 »

Thanks for the input.

Surprisingly, it worked with a fresh installed MT4.

I literally tried it on three MT4s on my Server. And it didn't work.
Reinstalled them and now it works fine.

Best Regards

tickstory
Posts: 4899
Joined: Sun Jan 06, 2013 12:27 am

Re: MT4 Strategy Tester Returns Zero for Other Timeframes

Post by tickstory »

Wow - that's interesting, Joe1310. That's something to add to our list of things to look out for ;) Thanks for letting us know!

Post Reply