Using Technical Analysis Indicators in Backtesting
Trading Platform Software for backtesting & auto trading, for stock, futures and forex trading systems › Forums › Tutorials › Using Technical Analysis Indicators in Backtesting
June 16, 2013 at 11:14 am #619
Technical analysis indicators are at the heart of any trading system, charts and in some cases other indicators. An indicator at the rawest form is simply a mathematical formula that generates one or more columns from a source set of columns, typically the Open, Close, High, Low and Volume. For more information on columns and how they relate to Seer, see Key concepts, Event programming.
Many of the default set of Indicators such as Lowest, Highest, EMA and others are internal to Seer itself, while others such as RSI, OBV and ADX are built using standard Seerscript. The source code for these Indicators can found under the indicators folder in the main treeview. There is no difference between how both these sets of indicators are used and called.
The source code of the ADX indicator
Using an indicator is simple, just use the name of the indicator and pass any required parameters. All indicators return one or more columns.
For example, if you wanted to use the Exponential Moving Average on the Close column:
Many indicators accept columns as parameters such as the EMA above, which can be the result of other indicators. For example, you could create a Simple Moving average of an Exponential Moving Average:
Some indicators such as ADX, MACD and BB return more than one column. In the case of the ADX, it returns 3 columns the ADX line, the DI+ and the DI-. When you use the ADX in scalar context, only the first Column (ADX line) is returned, for example, if you wanted to create an EMA of the ADX line you would simply do:
If you want to use the other columns the (DI lines) you have to use the indicator in list context:
In this case, the three variables contain the ADX line, the DI+ and the DI-. For example, say you wanted to calculate the EMA of the DI+ line:
my ($adx,$up,$down)=ADX(14); EMA($up,9)
Extracting values from Columns
In many cases you’ll just use the Column that is returned from an indicator, but sometimes you’ll want to extract and use specific values. The most common example is extracting the value from the current bar:
The function Now returns the value for the current bar. The Now function is a synonym of the function Today – both return the same value and can be used interchangeably.
Two other ways of returning values from the column are Previous (a synonym of Yesterday) and Ago:
#returns the value of the previous bar for the 9 bar EMA of the Close Previous(EMA(Close,9));
#returns the value of the 9 bar EMA of the Close 5 bars ago Ago(EMA(Close,9),5);
Why use Technical Analysis Indicators?
Performance wise, using indicators is extremely efficient – Seer uses a cashing formula where it is able to detect whether it has calculated an indicator before. If Seer has calculated the indicator, it is reused rather than recalculated. You should always use an indicator if you can.
Using Technical Analysis indicators is also a good way of encapsulating logic as stand alone units. Many complex trading systems often have components that can converted into Indicators, this reduces the complexity of the system, improves performance, encourages code reuse but most importantly it isolates components so that they can be easily tested and verified.
You must be logged in to reply to this topic.