How to extend price History in Strtegy tester

To add comments, please log in or register
ArashB
73
ArashB  

Dears,


first of all currently i'm using MQL5 for coding and during my coding on a strategy, i figured out there is a limited amount of history exist on each timeframe during backtesting.

as an example there is almost one year data exist for H1 timeframe over back test. this means if i start from 2019.01.01, the oldest date price which i have access to is 2018.01.02.

ISSUE 1: the main issue comes when i need to capture price information from 2014.01.01 (5 years) to calculate some changes.

unfortunately i couldn't find a proper way unless use below method which is not really good as it will waste time during back test :

void OnTick()
{
   CopyTime(_Symbol,0,0,1,Tm);
   if (Tm[0]<D'2019.01.01') return;
   .
   .
   .
}

it would be appreciated if anybody can inform me if there is a way to load more than basic specified period over backtesting.


ISSUE 2: is there any function to inform me what date selected as Tester start or end date?

Alain Verleyen
38084
Alain Verleyen  
ArashB:

Dears,


first of all currently i'm using MQL5 for coding and during my coding on a strategy, i figured out there is a limited amount of history exist on each timeframe during backtesting.

as an example there is almost one year data exist for H1 timeframe over back test. this means if i start from 2019.01.01, the oldest date price which i have access to is 2018.01.02.

ISSUE 1: the main issue comes when i need to capture price information from 2014.01.01 (5 years) to calculate some changes.

unfortunately i couldn't find a proper way unless use below method which is not really good as it will waste time during back test :

it would be appreciated if anybody can inform me if there is a way to load more than basic specified period over backtesting.

Yes there is around 1 year of past data in the Strategy Tester, it can vary a bit depending on the timeframe (it's explained in the documentation). So if you need more data (5 years or whatever) you need to set the starting date of your test accordingly, then add a parameter to your EA or indicator to "say" it when to effectively start (rather than using an hardcoded date as you did).

ISSUE 2: is there any function to inform me what date selected as Tester start or end date?

No. But it can be done with WinAPI calls.

ArashB
73
ArashB  

Thanks man,


on Issue1 : the way you suggested is the same way as i mentioned above. but as you know over strategy tester ontick event will run for all of those candles which are not useful at all (4 Years over ever tick is a real waste)

i thought maybe real experts like you have something or trick in their mind which seams not possible


on Issue2 : good hint. I got your point clearly and maybe i should go for it but frankly i never did this before. can you please drop a clue on my hand

tickfenix
92
tickfenix  

ISSUE 2: is there any function to inform me what date selected as Tester start or end date?

start: TimeCurrent() in OnInit()

end: TimeCurrent() in OnTester()

To add comments, please log in or register