Nov
27

Formula 201 – #8 Multiple Time Frame Access

One of the unique capabilities of NeoTicker indicator is its ability to process multiple time frame (MTF) information easily. I am going to explore the basic techniques of using MTF within formula indicator.

Creating Higher Time Frame with CompressSeries Function

To be able to access data or indicator values of another time frame, we have to first create a Compressed Series using the CompressSeries function. The general syntax of CompressSeries is as follows,

CompressSeries (SeriesName, LinkSeries, BarType, BarSize)

The parameter SeriesName is the name of the compressed series.

The parameter LinkSeries is the source series that we want to compress. It can be a data series, an indicator series, or even a variable series. The CompressSeries function will know exactly what to do with the series based on the type of data you are passing in.

The parameter BarType can be one of the following constants,

ppTick
ppSec
ppMin
ppHour
ppDaily
ppWeekly
ppMonthly
ppQuarterly
ppYearly

The parameter BarSize is an integer specifying the exact size of the designated BarType.

For example, if you are working on 1-minute data series, you can compress that into a 5-minute data series using CompressSeries,

CompressSeries (my5min, data1, ppMin, 5)

The compressed series my5min is created by the above function call. You can then use the series as if it is any other data series. For example, you can check if the close of the current 1-min bar is higher than the previous 5-min bar like this,

c > my5min.high (1)

There are many advantages in using compressed series over, say, directly collecting the previous 5-minute open, high, low, and close prices through series variables and local variables (something we have demonstrated in previous tutorials).

First, we can freely access any fields within the compressed series while using variable series will require the use of many variables to archieve the same. Second, we can access the previous values of all the fields exactly the same way we access them in the higher time frame without extra messy coding. Finally, a compressed series can be used as a link series in embedded indicators.

Combining Compressed Series with MakeIndicator Function

Talking about utilizing compressed series in indicators, remeber that there are two (2) ways in creating indicators.

First, the direct access way, e.g.

myaverage := average (my5min, 10)

Second, the MakeIndicator way, e.g.

makeindicator (myaverage, average, my5min, 10)

So what is difference? Or are they the same?

There is a big difference when my5min is a compressed series. Using the direct way to create an indicator, will result in a series having the same time frame as the primary series of the indicator.

When using the MakeIndicator function, the indicator instance created will inherit the time frame of the primary link. So, if the primary link is a compressed series, the indicator instance created by MakeIndicator will inherit the higher time frame from the compressed series.

Thus, the moving average myaverage created by MakeIndicator will be a truly 5-min based indicator, while the direct access one is a 1-min based series and not exactly the moving average we are looking for.

Here is a chart showing the moving averages we just discussed, with a reference moving average based on a hidden 5-min bar series.

formula201 part8 example

It looks like there is no difference between the two moving averages created by direct access method and the makeindicator method. The reason that they match is due to the fact that we are plotting the last values of the moving averages, and they should match when being examined at 1-minute interval. Also notice that at every 5 minute interval, the 1-minute based moving averages will synchronize with the reference 5-minute based moving average.

Now lets plot the 1-minute based moving averages using their values from 1 bar ago to see what happen. We are not changing the reference moving average so that we can observe the difference more easily.

formula201 part8 exampleS1

See how the MakeIndicator one having the same previous bar value throughout each 5-minute duration and then jump to the next value when a new 5-min bar is added. Thats because the MakeIndicator version is actually having the same time frame as the reference 5-minute based moving average.

The Advantage of Embedded Higher Time Frame Data Series and Indicators

Unlike working with an externally linked higher time frame indicator, an embedded higher time frame indicator get updated in the time frame of your formula indicator.

As we have seen in the first chart, you will be able to access the current bar intermediate values of the embedded 5-minute moving average on every minute.

You also have the advantage of being able to access the historical indicator values exactly the way you access them as in an actual 5-minute based data series, as seen in the second chart.

It is the best combination of both worlds.

How do we utilize such information? As a start, you can easily construct indicators based on multiple time frames. You will also be able to create trading systems that utilize information from multiple time frames easily.

Creating an Indicator Called Stochastic SlowK MTF

I am going to show you an indicator that is designed to work with daily data. It is called Stochastic SlowK MTF. What it does is very simple – combining the SlowK indicator values across daily, weekly, and monthly data using the same parameters.

Here is the Indicator Specification.

formula201 part8 indicator sepc

And the script.

formula201 part8 script

The indicator is pretty simple and self explanatory.

Here is an example chart with daily MSFT data.

formula201 part8 chart

The thick navy color line is the SlowK MTF indicator.

The thick dark red color line is a composite indicator that takes the average of 3 Stochastic SlowK indicators, all based on daily data only. Each SlowK indicator emulate the length of data needed to represent the daily, weekly, and monthly duration as used in the SlowK MTF indicator.

It is obvious that no matter how we combine the daily SlowK indicators, they will all go overbought or oversold too easily, due to the fact that they are all based on the same underlying daily data.

The SlowK MTF indicator is far superior in comparison as it does not jump into overbought and oversold zones too quickly and is much more stable in its movement.

Summary

Working with multiple time frames is not a complex concept. NeoTicker makes the concept easily accessible.

Complete Indicators

Stochastic SlowK MTF.

Donchian Bollinger Bands 3 Lines.

Exercise

1. Construct your own triple time frame composite moving average.

Answers For Previous Exercise

This indicator is called Donchian Bollinger Bands 3 Lines. The indicator has 3 parameters, 2 for the Bollinger Band settings, and an extra one for the moving window.

makeindicator (myband, bbands3, data1, param1, param2);
plot1 := myband.p1;
plot2 := hhv (myband.p2, param3);
plot3 := llv (myband.p3, param3);

Here is a chart of this indicator in action. It has the ability in smoothing out the Bollinger Band when it is reacting too fast to price swings.

formula201 part8 answer

You can download this indicator from the Complete Indicators section above.

Discuss this article.

One Comment on “Formula 201 – #8 Multiple Time Frame Access”

  1. Jay Says:

    Some fascinating ideas here for system development. Thanks. So glad I made the commitment to NeoTicker.

Leave a Comment

Blog Developed
By ContentRobot