Incremental Technical Analysis indicators

Hi @g-gundam and all

I wish you an happy new year 2024 !
Just a post to let you know the status of the lib

Here is a table showing current status of indicators porting

Name Description Input Output Dependencies Implementation status
AccuDist Accumulation and Distribution :candle: :1234: - :heavy_check_mark:
ADX Average Directional Index :candle: :m: ATR :heavy_exclamation_mark: Doesn’t work as expected - help wanted
ALMA Arnaud Legoux Moving Average :1234: :1234: CircBuff :heavy_check_mark:
AO Awesome Oscillator :candle: :1234: SMA :heavy_check_mark:
Aroon Aroon Up/Down :candle: :m: - :heavy_exclamation_mark: Doesn’t work as expected - help wanted (need to search in reversed list in order to get the right-most index)
ATR Average True Range :candle: :1234: CircBuff :heavy_check_mark:
BB Bollinger Bands :1234: :m: SMA, StdDev :heavy_check_mark:
BOP Balance Of Power :candle: :1234: - :heavy_check_mark:
CCI Commodity Channel Index :candle: :1234: MeanDev :heavy_check_mark:
ChaikinOsc Chaikin Oscillator :candle: :1234: AccuDist, EMA :heavy_check_mark:
ChandeKrollStop Chande Kroll Stop :candle: :m: CircBuff, ATR :heavy_check_mark:
CHOP Choppiness Index :candle: :1234: CirBuff, ATR :heavy_exclamation_mark: Doesn’t work as expected - help wanted
CoppockCurve Coppock Curve :1234: :1234: ROC, WMA :heavy_check_mark:
DEMA Double Exponential Moving Average :1234: :1234: EMA :heavy_check_mark:
DonchianChannels Donchian Channels :candle: :m: CircBuff :heavy_check_mark:
DPO Detrended Price Oscillator :1234: :1234: CircBuff, SMA :heavy_check_mark:
EMA Exponential Moving Average :1234: :1234: CircBuff :heavy_check_mark:
EMV Ease of Movement :candle: :1234: CircBuff, SMA :heavy_check_mark:
FibRetracement Fibonacci Retracement :question: :question: doesn’t look an indicator just a simple class with 236 382 5 618 786 values
ForceIndex Force Index :candle: :1234: prev input val, EMA :heavy_check_mark:
HMA Hull Moving Average :1234: :1234: WMA :heavy_check_mark:
Ichimoku Ichimoku Clouds :1234: :m: CircBuff 5 managed sequences :question: unit tests doesn’t exists in reference implementation
KAMA Kaufman’s Adaptive Moving Average :1234: :1234: CircBuff :heavy_check_mark:
KeltnerChannels Keltner Channels :candle: :m: ATR, EMA with input_modifier to extract close value of a candle :heavy_check_mark:
KST Know Sure Thing :1234: :m: SMA :heavy_exclamation_mark: Doesn’t work as expected - help wanted
KVO Klinger Volume Oscillator :candle: :1234: EMA :heavy_check_mark:
MACD Moving Average Convergence Divergence :1234: :m: EMA :heavy_check_mark:
MassIndex Mass Index :candle: :1234: EMA, CircBuff :heavy_check_mark:
McGinleyDynamic McGinley Dynamic :1234: :1234: CircBuff :heavy_check_mark:
MeanDev Mean Deviation :1234: :1234: CircBuff, SMA :heavy_check_mark:
OBV On Balance Volume :candle: :1234: prev input val :heavy_check_mark:
ParabolicSAR Parabolic Stop And Reverse :candle: :m: CirBuff :heavy_check_mark:
PivotsHL High/Low Pivots :candle: :m: - :construction: unit tests in reference implementation are missing.
ROC Rate Of Change :1234: :1234: CircBuff :heavy_check_mark:
RSI Relative Strength Index :1234: :1234: CircBuff, SMMA :heavy_check_mark:
SFX SFX :candle: :m: ATR, StdDev, SMA and input_modifier (to extract close) :heavy_check_mark:
SMA Simple Moving Average :1234: :1234: CircBuff :heavy_check_mark:
SMMA Smoothed Moving Average :1234: :1234: CircBuff :heavy_check_mark:
SOBV Smoothed On Balance Volume :candle: :1234: OBV, SMA :heavy_check_mark:
STC Schaff Trend Cycle :1234: :1234: MACD, Stoch with input_modifier (MACDVal->OHLCV and stoch_d->OHLCV), indicator chaining, MAFactory (default SMA) :heavy_check_mark:
StdDev Standard Deviation :1234: :1234: CircBuff :heavy_check_mark:
Stoch Stochastic :candle: :m: CircBuff, SMA :heavy_check_mark: :christmas_tree:
StochRSI Stochastic RSI :1234: :m: RSI, SMA :heavy_check_mark:
SuperTrend Super Trend :candle: :m: CircBuff, ATR :heavy_exclamation_mark: Doesn’t work as expected - help wanted
T3 T3 Moving Average :1234: :1234: EMA with indicator chaining and input filter :heavy_check_mark:
TEMA Triple Exponential Moving Average :1234: :1234: EMA :heavy_check_mark:
TRIX TRIX :candle: :m: EMA, indicator chaining :heavy_check_mark:
TSI True Strength Index :1234: :1234: EMA, indicator chaining :heavy_check_mark:
TTM TTM Squeeze :candle: :m: SMA, BB, DonchianChannels, KeltnerChannels and input_modifier to extract close value of a candle :heavy_check_mark:
UO Ultimate Oscillator :candle: :1234: CircBuff :heavy_check_mark:
VTX Vortex Indicator :candle: :m: CircBuff, ATR :heavy_exclamation_mark: Doesn’t work as expected - help wanted
VWAP Volume Weighted Average Price :candle: :1234: - :heavy_check_mark:
VWMA Volume Weighted Moving Average :candle: :1234: CircBuff :heavy_check_mark:
WMA Weighted Moving Average :1234: :1234: CircBuff :heavy_check_mark:
ZLEMA Zero Lag Exponential Moving Average :1234: :1234: EMA :heavy_check_mark:

We have now 52 technical indicators.

As you can see StochRSI (and many others indicators have been) implemented.
We have now a mechanism for indicator chaining.

What is indicator chaining?

Indicator chaining is like using Lego blocks to create unique combinations. When you chain indicators together, output of one indicator is the input of the following indicator.

T3 for example is composed of 6 EMA (Exponential Moving Average) which are chained

So by chaining them you can replace code like


function _calculate_new_value(ind::T3)
    _ema1 = value(ind.ema1)
    if !ismissing(_ema1)
        fit!(ind.ema2, value(ind.ema1))
        _ema2 = value(ind.ema2)
        if !ismissing(_ema2)
            fit!(ind.ema3, _ema2)
            _ema3 = value(ind.ema3)
            if !ismissing(_ema3)
                fit!(ind.ema4, _ema3)
                _ema4 = value(ind.ema4)
                if !ismissing(_ema4)
                    fit!(ind.ema5, _ema4)
                    _ema5 = value(ind.ema5)
                    if !ismissing(_ema5)
                        fit!(ind.ema6, _ema5)
                    end
                end
            end
        end
    end

    if has_output_value(ind.ema6)
        return ind.c1 * value(ind.ema6) +
               ind.c2 * value(ind.ema5) +
               ind.c3 * value(ind.ema4) +
               ind.c4 * value(ind.ema3)
    else
        return missing
    end
end

by something much simpler such as


function _calculate_new_value(ind::T3)
    if has_output_value(ind.ema6)
        return ind.c1 * value(ind.ema6) +
               ind.c2 * value(ind.ema5) +
               ind.c3 * value(ind.ema4) +
               ind.c4 * value(ind.ema3)
    else
        return missing
    end
end

See T3 code

We also have now a input_filter/input_modifier functions for every indicators so we can for example feed a SISO indicator (single input single output) with candle data (OHLCV) when passing also an input_modifier function which take for example close price of a candle.

A good example of indicator which use such a mechanism is TTM (probably the most complex indicator I have implemented currently)

https://school.stockcharts.com/doku.php?id=technical_indicators:ttm_squeeze

TTM uses BB (Bollinger Bands), DonchianChannels, KeltnerChannels and a moving average (SMA by default but any other moving average can be used thanks to a moving average factory (MAFactory))

See TTM Squeeze code

Here is status of unit tests

Precompiling project...
  1 dependency successfully precompiled in 5 seconds. 45 already precompiled.
     Testing Running tests...
┌ Warning: WIP - buggy
└ @ IncTA C:\Users\femto\.julia\dev\IncTA\src\indicators\KST.jl:72
┌ Warning: WIP - buggy
└ @ IncTA C:\Users\femto\.julia\dev\IncTA\src\indicators\CHOP.jl:32
┌ Warning: WIP - buggy
└ @ IncTA C:\Users\femto\.julia\dev\IncTA\src\indicators\ADX.jl:49
┌ Warning: WIP - buggy
└ @ IncTA C:\Users\femto\.julia\dev\IncTA\src\indicators\SuperTrend.jl:45
┌ Warning: WIP - buggy
└ @ IncTA C:\Users\femto\.julia\dev\IncTA\src\indicators\VTX.jl:39
┌ Warning: WIP - buggy
└ @ IncTA C:\Users\femto\.julia\dev\IncTA\src\indicators\Aroon.jl:31
Test Summary: | Pass  Broken  Total   Time
IncTA.jl      |  788       6    794  29.2s
     Testing IncTA tests passed

So we still have some indicators which doesn’t behave like reference implementation (talipp). I must admit that I haven’t searched quite a long time on each… but enough to lose patience.

If some of you want to have a look, PR are welcome ! I think a good way to fix this could be to install latest development version of talipp (v2.x) and do some “print debugging” on internal state of indicator

Doc also need to be improved (and published !).

This project is not really complex but very time consuming given the number of indicators which are reimplemented in pure Julia (contrary to TALib.j which was a wrapper around C library talib !

My hope will be to have this lib used by some others (especially those who are building backtesters)

2 Likes