When The predefined timeframes are not enough

 

Hello everyone,

I have developed a trading strategy that relies heavily on functions such as iHighest , iLowest , and iRSI .
The logic works very well on standard timeframes ( M30, H1, H2, H3,  H4, H6, H8, H12, D1 and W1), but I have reached a limitation:

The predefined timeframes in MT5 are not enough for my strategy.

For example, I would like to use custom timeframes such as:

  • 1 hour 30 minutes (H1.5)

  • 2 hours 30 minutes (H2.5)

  • 3 hours 30 minutes (H3.5)

  • And so on…

My goal:
To extend my strategy by adding intermediate timeframes, while still being able to use the same built-in functions ( iHighest , iLowest , iRSI ) in a multi-symbol / multi-timeframe environment.

My question:
Is there any proper or efficient way to create and use custom timeframes inside MT5, that will work both on Strategy Tester and Live so they behave just like native timeframes for indicator/EAs logic?

Possible approaches I’ve considered:

I can get the iopen iclose ihigh and ilow prices using the function from this thread https://www.mql5.com/en/forum/482926 but i do not know how to use them on my  iHighest ,  iLowest ,  iRSI void's


If anyone has solved this problem or can suggest the best practice, I would really appreciate your guidance.

Thank you!

 

Either build the non-standard time-frames internally in the EA on the fly as you need them, or use a standard time-frames and adjust the period of the functionality you wish to use.

For example, using iHighest() of 20 bars on H1.5 (3 x M30) is equivalent to 60 bars on M30. Just synchronise the start or end points according to your alignment rules.

 
Fernando Carreiro #:
bars on H1.5 (3 x M30
problem with  iHighest() solved, but what about the RSI?
 
Ioannis Christopoulos #problem with  iHighest() solved, but what about the RSI?

The same method applies ...

Forum on trading, automated trading systems and testing trading strategies

How to Display Indicators in a Different Timeframe in an EA?

Fernando Carreiro, 2024.12.13 16:38

... just scale the Moving Average period to get an equivalent moving average of the different time-frames (see example below).

Example of equivalent periods: A SMA(20) on H2 translates to a SMA(40) on H1. It will obviously be slightly different because H1 has more resolution than H2, but will be equivalent.

 
Ioannis Christopoulos:

The predefined timeframes in MT5 are not enough for my strategy.

For example, I would like to use custom timeframes such as:

  • 1 hour 30 minutes (H1.5)

  • 2 hours 30 minutes (H2.5)

  • 3 hours 30 minutes (H3.5)

  • And so on…

It's possible to work from a base timeframe such as H1 and then only update the indicators every 1.5 hours or whatever you want through the use of boolean states and time rules. In this way it is a custom period that is extended from a native timeframe (such as H1).

 

this is a simple indicator to demonstrate what I mean, but not that simple to code unless you understand modulus

To demonstrate...in this indicator, a line is drawn at the time of a 1.5 hour timeframe.

I use MqlRates, so you can easily use the same code in an expert advisor. Use whichever base timeframe suits best depending on how granular you want the time update to be.