trendspider facebook

How to use Offsets in your Alerts or Backtests

TrendSpider now supports offsets in alert and backtest templates. This post will explain how offsets work and when you should use them.

What are offsets?

Offsets allow you to compare events that occurred in the past or in a sequence. This is useful with lagging indicators such as the Ichimoku Cloud’s Chikou Span line which is set-back by 26 candles. Without an offset option, you would not be able to create an accurate signal from this indicator because you would be comparing a past-value against a present-value.

Offsets also allow you to compare events that occurred in sequence, compare conditions which may have been met at different times, together in one alert.

How to use Offsets with Lagging Indicators

Here’s a picture featuring 2 indicators: SMA(20) [red] and SMA(20, offset = -10) [blue]. The latter has negative offset, thus we’re calling it “lagging”. You can see the circles marking respective offsets.

From this picture above, you can see that in case if you seek for a “red SMA is greater than blue SMA” kind if condition, then you need to code it like “red SMA (10 candles ago) > blue SMA”

Using the Ichimoku Cloud example, to create an alert when the Chikou Span line crosses up through the Tenkan Sen line, you would create the condition as normal.

A warning will appear to inform you that one of the conditions you are using is a lagging or offset indicator.

In order to make your comparison accurate here, you would need to then offset the comparison indicator by the same value. You can see in the above example, we have entered 26 in the ‘candles ago’ field for the Tenkan-Sen line.

Using Offsets to detect series of events

Offsets can also be used to identify events that occur in a sequence. In the following example, we are looking for 3 red candles in a row, with each candle having closed lower than the one before it. By using offsets, we are able to create a simple set of conditions that will detect this pattern for any backtest or alert. You can see that the offsets are escalated to set-back each set of candle parameters in order to create a sequence condition that will fire only when three candles, in a row, are red, and close below the close of the previous one.

This type of sequencing can be used to create complex conditional alerts such as those used in the TD Sequential indicator.