Stuck in tester 4 different time frames

 

Dears,

I'm sorry, I read around and searched, but I'm stuck in the tester. I understand it should work, but it doesn't :(

I run (tester) an EA on a 1H chart and I try to get values from iMomentum for the 15M period. The function always returns 0. For the live of me, I can't find out, why?? Pardon-me, for 1 line of code:

double Momentum_15 = iMomentum(NULL, PERIOD_M15, 4 ,PRICE_TYPICAL, 0);


Any suggestions ?


Thank's in advance

hk.

 

Hi All,


sorry, just found it.

I call it as iCustom; works now

Momentum_15    = iCustom(NULL,0,"Momentum",PERIOD_M15,4,PRICE_TYPICAL,0,0)

Cheers

hk

 

Still sorry, back to sqare 0.

Momentum.mq4 is not iMomentum.

Hence the problem still exists 4me.


I can't get Momentums of 15M in an EA running under tester in a 1H Chart.

Rgds

hk

 
Change the tester timeframe to 15 minutes it should work.
 

Hi Damian,


not sure, if I got you right...

I need the EA to work on 1H candles and timeframes. I just want the 15M iMomentum underneath.

If I switch the tester to 15M, everything works on 15M, - right??


Best Regards

hk

 

Hi Damian,


sorry, I do not understand at all, what you try to explain 2me.

Thanks anyway.


BTW,

everything works like a charme, if I use iMomentum at the chart time frame,

double Momentum_15 = iMomentum(NULL, 0, 4 ,PRICE_TYPICAL, 0);


Rgds

hk

 

OK, thank you


thats what I posted there. Its an old thread, thats why I repeat it here.

Hi,

due to some help from Alain, I came across this thread. I guess the clue that it aparently works is, that you run at 1M and all other time periods are higher. I tried the MT4 strategy tester, and its written somewhere, that you can access multiple time frames in the strategy tester, as long as they are higher than the time frame you are running the tester and as long as they are multiples. e.g. 1H = 4*15M; 4h = 48*5M etc. You cannot go to lower time periods e.g. running at 1H and trying to access 15M.


Rgds

hk
 

At All,

I try to be a bit more systematic. May be someone could explain me:

Assume a custom indicator, which takes only 1 Input "MyInput"

Assume the custom indicator calls internally iMomentum w/ time frame = PERIOD_15M

Calling the custom indicator from an EA would use the iCustom call

double  iCustom(
   string       symbol,           // symbol
   int          timeframe,        // timeframe

   string       name,             // path/name of the custom indicator compiled program

and the input parameter "MyInput".


Question: What does the timeframe parameter of the iCustom function do, for what is it?

Since the custom indicator itself does not expect any timeframe as input, I assume, it is not passed to the custome indicator?!

so for what is it? Assume I run the strategy tester at 15M and the iCustom timeframe parameter would be at 1H, does that mean, that the custom indicator is not called?

If the setup is as above EA tester at 15M, timeframe parameter w/in the iCustom call ist 1H, when will on calculate events appear in the custom indicator and at what granularity will they change? 1H or 15M or tick by tick??


Sorry for sooooooo many difficult questions


Best Regards

hk


 
lve0200:

At All,

I try to be a bit more systematic. May be someone could explain me:

Assume a custom indicator, which takes only 1 Input "MyInput"

Assume the custom indicator calls internally iMomentum w/ time frame = PERIOD_15M

Calling the custom indicator from an EA would use the iCustom call

double  iCustom(
   string       symbol,           // symbol
   int          timeframe,        // timeframe

   string       name,             // path/name of the custom indicator compiled program

and the input parameter "MyInput".


Question: What does the timeframe parameter of the iCustom function do, for what is it?

Since the custom indicator itself does not expect any timeframe as input, I assume, it is not passed to the custome indicator?!

so for what is it? Assume I run the strategy tester at 15M and the iCustom timeframe parameter would be at 1H, does that mean, that the custom indicator is not called?

If the setup is as above EA tester at 15M, timeframe parameter w/in the iCustom call ist 1H, when will on calculate events appear in the custom indicator and at what granularity will they change? 1H or 15M or tick by tick??


Sorry for sooooooo many difficult questions


Best Regards

hk


I read all the other topic (https://www.mql5.com/en/forum/39662) and it looks it possible to backtest MTF in mt4 read Dr Matthias Hammelsbeck post he even post a video .NOTE: I deleted some of other post because were too missleading .
 

Hi, yes I read this before and I replied there.

After an evening of hard work, I found the solution; let me shed some light on this very complex subject:

Assume the tester runs in a 15M timeframe!

the following call to a custom indicator

double  iCustom(
   string       symbol,           // symbol
   int          timeframe = PERIOD_1H,        // timeframe

   string       name,             // path/name of the custom indicator compiled program

and the input parameter "MyInput".


does the following:

The custom indicator is initiated in an 1H environment, although the tester runs at 15M. On Calculate events in the custom indicator are generated tick_by_tick w/ an rate array of 1H candles as input.

Subsequent calls to e.g.  iMomentum inside the custom indicator w/ timeframe = PERIOD_15M generate the proper Momentum of 15M candles. This is possible, because the timeframe of the custom indicator (1H) is superior and multiple of the tester timeframe and the requested timeframe of the iMomentum call is equal to the tester timeframe. If the tester would run at 1H, there would be no impact on the custom indicator, but the call to iMomentum would fail and always return 0, because his time frame of 15M is below the tester timeframe.


From here, we can define some general rules for testing MTF EAs in MT4 Tester:

  1. Testing MTF EAs in MT4 is possible as long as calls to different time frames in the EA are to higher timeframes as the time frame the tester itself runs at; these higher timeframes must be multiples
  2. You must use explicit timeframes Constants in all your calls, e.g. PERIOD_15M or PERIOD_4H etc; NULL, 0 or PERIOD_CURRENT are not allowed; if you choose to ignore this, your EA will produce different results at different tester timeframes. That means, you must conciously decide in which target timeframe your MTF EA shall run in real life. If you want to keep the freedom to let the MFT EA run at any chart timeframe, you just happen to choose at a time, you will need to use the isTester() function to setup conditional code for testing; this will be very very complex.
  3. The tester timeframe must be equal or less as the lowest requested timeframe in the EA and all calls in its subroutine stack.

Hope that helps


Good trades

hk

Reason: