TA-Lib is an open source library of over 150 customizable indicators and mathematical functions that we are incorporating into our screening code. This gives you the ability to test new strategies and fine tune your existing ones.
We are currently releasing the library with support limited to nine popular indicators including two moving averages (EMA and SMA) and seven momentum indicators (ADX, AROON, CCI, MACD, PPO, ROC, and RSI). Other indicators will be released over the next few days, but these most popular indicators are ready to go.
The process to include an indicator into your screen is the same as defining a user variable. Just click on the Add/Create button to open the variable definition box and then click the TA-Lib Helper button in the lower right corner. This action opens some drop-down selectors you can use to locate your indicator of choice and, if appropriate, select an output option.
Most indicators like SMA and ROC take a single input series and output a single series. With these you usually input price and output a moving average or rate of change. Other indicators are more complex with multiple inputs and/or multiple outputs. For example, in the last image above the chosen indicator is MACD. Since this indicator outputs three data series (the MACD, the MACD Signal, and the MACD Histogram) the user must select which they want, in this case the MACD Histogram. If the user wants two or more of the outputs they must define a user variable for each since a user variable is limited to a single data series. For most indicators that only output a single series, there is no option for an output series.
While you can type a definition into the Define box it is easier and less error prone to click the “Copy to above” link and let the system copy a default rule to the define box. From there you can customize either the input fields or the various indicator options. For those indicators that utilize price data just enter the [Price] field like the default. This will reference closing data for most indicators, but also make available open, high, low, and volume for indicators that need those fields, like Commodity Channel Index (CCI) and a number of others.
Remember to name your user variable something meaningful and then click OK to save the UV to your screen. After that, you reference the UV just like any other.
It is beyond the scope of this post to define each indicator and the options available, but most are intuitive if you are familiar with the indicator from other systems. There is some information available on the TA-Lib Home Page, but a better source for the indicators is probably at this Python related site.
Below are a few examples of TA-Lib function codes:
TaLib(EMA, [Price], 20) – A 20-day Exponential Moving Average(EMA) of the closing prices.
TaLib(SMA, [RSf], 10) – A 10-day Simple Moving Average(SMA) of RSf. Note you can reference any standard data field, or even another user variable as input.
TaLib(MACD, MACDHist, [Price], 12, 26, 9) – Here an MACD is being defined and you will see is requires more inputs that the simple moving averages shown above. After the indicator (MACD) is specified an output field must be specified, here it is MACDHist for the histogram data. After that there are the three defining inputs required for an MACD. The first two are EMA lengths for calculating two moving averages and the third is used for calculate the signal line. More information on this and other indicators can be found on Investopedia.
TaLib(EMA, [ _EMA1], 5) – An indicator can reference the output of another by referencing the variable name as input. Here, if EMA1 had previously been defined as TaLib(EMA, [Price], 20), then the above would give you the 5-day moving average of the 20-day moving average.
PREVAL([_EMA1], 21) – The PREVAL function can be utilized to reference the value of an indicator some days in the past. In this example we are referencing the value of a variable we named _EMA1, 21 days prior. Utilizing this one can determine whether an indicator is rising or falling over some time period. In testing we’ve used this in a filter rule to determine if OBV values were rising over the past month.
We recognize a few additions that need to be made to the text box describing the indicator, like including the name and describing what each option field does. These tweaks will be made in the near future, but please provide us feedback on other changes that need to occur.
We also need feedback on how to present the Volume based indicator values: AD, ADOSC, and OBV. These indicators are designed for chart reading and the actual numerical values are meaningless. For the purposes of this site, how should this data be presented? We’ve considered moving average relationships, changes in a moving average over time, and even linear regression slope. We’re confident there are better options out there so we’re asking for help. In the meantime these indicators are currently unavailable due to related technical issues.
We’re excited about the possibilities of this new library as it opens many doors for our users to explore. It’s probably obvious, but these customizations are reserved for our Premium Access users.
Enjoy and please provide feedback.