Adapt Your Parameters to the Time Frame

We all know that picking a smaller time frame for trading and backtesting means more trades but also more noise. As a trader or quant, you can adapt your parameters to the time frame very easily. For example, using X as period for a moving average in a daily chart, but Y as period for the SMA in an hourly chart. This short article explains how to code this in Equilla.

Adapt Your Parameters to the Time Frame – with these two Functions

Creating the code for the purpose mentioned above is easy, because we can retrieve the time frame of the chart with pre-built functions. Using the function Bartype, we can control each if .. then .. statement based on the underlying time frame of the chart. Here are some examples:

BarType Function in Equilla

Another way to use the time frame of an underlying chart for selecting the parameters, is a function called BarInterval. This function reflects the number of minutes of the selected time frame. Let`s say we would like to use a specific parameter setting only for the hourly chart. This can be done by using the following expression:

BarInterval Function in Equilla

Simple Equilla Code

Now that we know both functions, we can build the code for our dummy indicator. We would like to use a moving average with period 5 for the daily chart. Whenever we switch to the hourly chart, a moving average period of 10 shall be used. Here`s how the code looks:

  • In line 4 we define the moving average by declaring the variable avg.
  • Lines 6 and 9 contain the functions mentioned before and control the period for the SMA.
  • In line 12, I added a simple print command so that the SMA parameter for a given chart will be displayed in the output window – a good way to check whether the code works properly.

Adapt your parameters to time frame Code

Be creative!

This simple dummy indicator shows the basic concept of adapting the parameters of an indicator or trading strategy to the underlying time frame chart. You can use this approach to create many different rules, for example using a specific stop for intraday bars and another for time frames above daily. Start coding today and convert your ideas into profits.


Copyright (c) Terms of use: /terms-conditions/

Tradesignal® is a registered trademark of Tradesignal GmbH. Unauthorized use or misuse is strictly prohibited.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to this Blog