Technical Analysis Indicator Function Library in C


Build Status

Tulip Indicators


Tulip Indicators is a library of technical analysis functions written in ANSI C.

Lots of information is available on the website:

High quality bindings are available for Node.js, Python, and .NET.


  • ANSI C with no dependencies.
  • Uses fast algorithms.
  • Easy to use programming interface.
  • Release under LGPL license.


Building is easy. You only need a decent C compiler. Tulip Indicators has no other dependencies.

Just download the code and run make.

git clone
cd tulipindicators

You should get a static library, libindicators.a. You'll need that library and the header file indicators.h to use Tulip Indicators in your code.


For usage information, please see:

Indicator Listing

104 total indicators

   avgprice            Average Price
   bbands              Bollinger Bands
   dema                Double Exponential Moving Average
   ema                 Exponential Moving Average
   hma                 Hull Moving Average
   kama                Kaufman Adaptive Moving Average
   linreg              Linear Regression
   medprice            Median Price
   psar                Parabolic SAR
   sma                 Simple Moving Average
   tema                Triple Exponential Moving Average
   trima               Triangular Moving Average
   tsf                 Time Series Forecast
   typprice            Typical Price
   vidya               Variable Index Dynamic Average
   vwma                Volume Weighted Moving Average
   wcprice             Weighted Close Price
   wilders             Wilders Smoothing
   wma                 Weighted Moving Average
   zlema               Zero-Lag Exponential Moving Average

   ad                  Accumulation/Distribution Line
   adosc               Accumulation/Distribution Oscillator
   adx                 Average Directional Movement Index
   adxr                Average Directional Movement Rating
   ao                  Awesome Oscillator
   apo                 Absolute Price Oscillator
   aroon               Aroon
   aroonosc            Aroon Oscillator
   atr                 Average True Range
   bop                 Balance of Power
   cci                 Commodity Channel Index
   cmo                 Chande Momentum Oscillator
   cvi                 Chaikins Volatility
   di                  Directional Indicator
   dm                  Directional Movement
   dpo                 Detrended Price Oscillator
   dx                  Directional Movement Index
   emv                 Ease of Movement
   fisher              Fisher Transform
   fosc                Forecast Oscillator
   kvo                 Klinger Volume Oscillator
   linregintercept     Linear Regression Intercept
   linregslope         Linear Regression Slope
   macd                Moving Average Convergence/Divergence
   marketfi            Market Facilitation Index
   mass                Mass Index
   mfi                 Money Flow Index
   mom                 Momentum
   msw                 Mesa Sine Wave
   natr                Normalized Average True Range
   nvi                 Negative Volume Index
   obv                 On Balance Volume
   ppo                 Percentage Price Oscillator
   pvi                 Positive Volume Index
   qstick              Qstick
   roc                 Rate of Change
   rocr                Rate of Change Ratio
   rsi                 Relative Strength Index
   stoch               Stochastic Oscillator
   stochrsi            Stochastic RSI
   tr                  True Range
   trix                Trix
   ultosc              Ultimate Oscillator
   vhf                 Vertical Horizontal Filter
   volatility          Annualized Historical Volatility
   vosc                Volume Oscillator
   wad                 Williams Accumulation/Distribution
   willr               Williams %R

   crossany            Crossany
   crossover           Crossover
   decay               Linear Decay
   edecay              Exponential Decay
   lag                 Lag
   max                 Maximum In Period
   md                  Mean Deviation Over Period
   min                 Minimum In Period
   stddev              Standard Deviation Over Period
   stderr              Standard Error Over Period
   sum                 Sum Over Period
   var                 Variance Over Period

   abs                 Vector Absolute Value
   acos                Vector Arccosine
   add                 Vector Addition
   asin                Vector Arcsine
   atan                Vector Arctangent
   ceil                Vector Ceiling
   cos                 Vector Cosine
   cosh                Vector Hyperbolic Cosine
   div                 Vector Division
   exp                 Vector Exponential
   floor               Vector Floor
   ln                  Vector Natural Log
   log10               Vector Base-10 Log
   mul                 Vector Multiplication
   round               Vector Round
   sin                 Vector Sine
   sinh                Vector Hyperbolic Sine
   sqrt                Vector Square Root
   sub                 Vector Subtraction
   tan                 Vector Tangent
   tanh                Vector Hyperbolic Tangent
   todeg               Vector Degree Conversion
   torad               Vector Radian Conversion
   trunc               Vector Truncate

Special Thanks

The stochrsi indicator was sponsored by: Gunthy.

  • Recursive indicators' output fluctuation

    Recursive indicators' output fluctuation

    Some indicators are defined by infinite recursive formulas, hence their results differ depending on the bar we begin the computation at.

    Consider this example: EMA indicator with a 5 days rolling window, fed with two slightly different inputs:

    {25.000,24.875,24.781,24.594,24.5,24.625,25.219,27.25} -> {25.000,24.958,24.899,24.797,24.698,24.674,24.856,25.654}
    {       24.875,24.781,24.594,24.5,24.625,25.219,27.25} -> {       24.875,24.844,24.760,24.674,24.657,24.845,25.646}

    Please note how numbers change. To use the library in practice, we need a way to reproduce the same values of the indicator on the same bars, even if we add or remove some price history to/from the start of the input price data.

    We propose a solution: to introduce an additional option, "seed", that would allow us to mock the result of the infinite recursive computation on the [absent] preceding data, or, in other words, to pass the initial value to the indicator, if needed.

    isnan(seed) would express then our intention for the indicator to calculate the value by itselt, just the way it does now.

    Other indicators subject to this issue include (but not limited to):

    • adx
    • atr
    • bbands
    • cmo
    • decay
    • trics
    • di
    • dm
    • dpo
    • dx
    • edecay
    • ema
    • kama
    • hma

    What do you think about it?

    /cc @HelloCreepy

    opened by rdbuf 13
  • Divide by Zero in ADX, ADXR, DI, and DX

    Divide by Zero in ADX, ADXR, DI, and DX


    These formulas divide by ATR, which could be zero. Currently a divide-by-zero results in returning NaN. We should consider if this is appropriate or not.

    discussion wanted 
    opened by codeplea 12
  • Chandelier Exit indicator

    Chandelier Exit indicator


    • Alexander Elder. Come Into My Trading Room, 2002, pp. 180-181. ISBN: 9780471225348
    • J. Welles Wilder. New Concepts in Technical Trading Systems, 1978, pp. 21-23. ISBN: 9780894590276
    1. True Range:


    1. Average True Range:


    1. Chandelier Exit, ce_high:


    1. Chandelier Exit on short positions, ce_low:


    opened by rdbuf 10
  • don't understand how to use the macd function

    don't understand how to use the macd function


    I'm trying to use the ti_macd() function. The initial parameters are: 12, 26, 9 I call the ti_macd_start() function as follows:

    const double options[] = {
    std::size_t produced = ti_macd_start(options);

    Now the produced var is equal 25. I have the std::vector<double> with size 26. Next, I allocate the std::vector<double>s for outputs and call the ti_macd() as follows:

    std::vector<double> inarr = {...}; // 26 doubles with closed vals
    const double *inputs[] = {&inarr[0]};
    std::vector<double> macd_fast(produced);
    std::vector<double> macd_slow(produced);
    std::vector<double> macd_hist(produced);
    double *outputs[] = {
    int ec = ti_macd(slow_period, inputs, options, outputs);

    After that in the macd_fast and macd_slow vectors only first element is not null. However the macd_hist vector contains only zeros.


    opened by Tasheehoo 10
  • Optimizing Rolling Window Indicators

    Optimizing Rolling Window Indicators

    Regarding most of the rolling window indicators for example SMA,

    Why isn't the previously calculated SMA Indicator used as an optimization similar to dynamic programming?

    For e.g in SMA didn't we only need to exclude the oldest period value in average and include the latest period value to calculate one additional point in SMA ?

    I see that most of the indicators are like this. Performance gain by this should be huge. Am i missing something ?

    opened by G8XSU 9
  • Use CMake for building [WIP]

    Use CMake for building [WIP]

    Currently, we build with a gnumake script. It causes a race condition at code generation stage. I don't think it worth it to waste time trying to come up with a fix; rather, I propose using a cmake script that causes a lot less problems.

    Code generation happens at the configuration stage, i.e. when doing cmake ...

    benchmark.c is currently unsupported.

    A lot of ideas were borrowed from #27.

    opened by rdbuf 8
  • Added indicator streams and reference indicators

    Added indicator streams and reference indicators

    Indicator streams Reference indicators

    indicators.tcl now takes an extra parametr for each indicator. This option can be "ref" or "stream" or both. It'll generate code accordingly.

    I used ATR as the first example. ATR is easy to make a reference for (call ti_tr, call ti_wilders) and it's easy (but not trivial) to make a streaming indicator for.

    I updated smoke to check ref and stream if available.

    I updated the Makefile to c99. It's a lot easier.

    opened by codeplea 7
  • [indicator request] Zigzag

    [indicator request] Zigzag

    Is there a chance of getting the indicator "zigzag" supprted including deepth? The zigzag is quite important to filter out noice and for determent eliot waves, as well as to better find petterns like double bottom etc.

    I read in issue #36 you saying "However, if an indicator includes data from the future, then you have a data leak. This is why I've never implemented the popular Zig-zag indicator", but I cannot understand why you say that zigzag is based on data from the future, as the completion of the last zigzagline should be just an option and not an fact. In adition if you have a look at the indicator on tradingview you will find another option "deepth" which in addion tells should prevent somehow to draw the zigzag line too early propertly wrong.

    Hopefully you wil find the time to implement this


    opened by LooOOooM 6
  • Add Arnaud Legoux Moving Average indicator & tests

    Add Arnaud Legoux Moving Average indicator & tests

    I've implemented the Arnaud Legoux Moving Average and added some test cases. I've tried to optimize it but I'm not an expert in C so please review the code.

    I personally use the node bindings for tulip indicators and would like to use this specific indicator there. Created this pull request in case it's something you would like to add to the library, otherwise I will probably maintain a private fork of this repo + node bindings for my own use.


    • I could not get the TCL scripts to run so I did my best to add the indicator manually, but it's also added to the scripts so that it should (hopefully) be properly added if run by somone else
    • Perhaps add a new error code for malloc errors.
    • Perhaps I should use the buffer utility struct instead of allocating manually

    Thanks for the cool library!

    opened by johanhenriksson 6
  • Add StochRSI

    Add StochRSI


    Can you add StockRSI indicator :

    Or maybe i can use stoch and rsi to get it ?

    thank you for this awesome library

    opened by Patafix 5
  • Docs Duplicate Indicator to %R: Quality Factor (%Q)

    Docs Duplicate Indicator to %R: Quality Factor (%Q)

    First off thanks for this great library.

    This is something I noticed when looking for the Quality Factor (%Q) indicator (Ref, page 5) and looking at the docs on Williams %R.

    %Q is %R without the -100 multiplier. Maybe something to add to the docs. I would have submitted a PR but didn't know how for this.

    opened by kevindirect 4
  • MacbookPro m1 build failed!!!!

    MacbookPro m1 build failed!!!!

    When build with m1 MackBookPro ,I got a error!!!!

    ar rcu libindicators.a indicators.h candles.h indicators.c candles.c indicators/abs.o indicators/acos.o indicators/ad.o indicators/add.o indicators/adosc.o indicators/adx.o indicators/adxr.o indicators/ao.o indicators/apo.o indicators/aroon.o indicators/aroonosc.o indicators/asin.o indicators/atan.o indicators/atr.o indicators/avgprice.o indicators/bbands.o indicators/bop.o indicators/cci.o indicators/ceil.o indicators/cmo.o indicators/cos.o indicators/cosh.o indicators/crossany.o indicators/crossover.o indicators/cvi.o indicators/decay.o indicators/dema.o indicators/di.o indicators/div.o indicators/dm.o indicators/dpo.o indicators/dx.o indicators/edecay.o indicators/ema.o indicators/emv.o indicators/exp.o indicators/fisher.o indicators/floor.o indicators/fosc.o indicators/hma.o indicators/kama.o indicators/kvo.o indicators/lag.o indicators/linreg.o indicators/linregintercept.o indicators/linregslope.o indicators/ln.o indicators/log10.o indicators/macd.o indicators/marketfi.o indicators/mass.o indicators/max.o indicators/md.o indicators/medprice.o indicators/mfi.o indicators/min.o indicators/mom.o indicators/msw.o indicators/mul.o indicators/natr.o indicators/nvi.o indicators/obv.o indicators/ppo.o indicators/psar.o indicators/pvi.o indicators/qstick.o indicators/roc.o indicators/rocr.o indicators/round.o indicators/rsi.o indicators/sin.o indicators/sinh.o indicators/sma.o indicators/sqrt.o indicators/stddev.o indicators/stderr.o indicators/stoch.o indicators/stochrsi.o indicators/sub.o indicators/sum.o indicators/tan.o indicators/tanh.o indicators/tema.o indicators/todeg.o indicators/torad.o indicators/tr.o indicators/trima.o indicators/trix.o indicators/trunc.o indicators/tsf.o indicators/typprice.o indicators/ultosc.o indicators/var.o indicators/vhf.o indicators/vidya.o indicators/volatility.o indicators/vosc.o indicators/vwma.o indicators/wad.o indicators/wcprice.o indicators/wilders.o indicators/willr.o indicators/wma.o indicators/zlema.o utils/buffer.o indicators.o candles.o
    ranlib libindicators.a
    gcc -c -Wall -Wextra -Wshadow -Wconversion -std=c99 -pedantic -O2 -g sample.c -o sample.o
    gcc -Wall -Wextra -Wshadow -Wconversion -std=c99 -pedantic -O2 -g -o sample sample.o libindicators.a -lm
    ld: warning: ignoring file libindicators.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
    Undefined symbols for architecture arm64:
      "_ti_find_indicator", referenced from:
          _main in sample.o
      "_ti_indicators", referenced from:
          _main in sample.o
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [sample] Error 1
    opened by UnivexDont 1
  • Default options for indicators?

    Default options for indicators?

    Can you please consider adding default option values to indicator descriptors? I'm making a charting application where the user can add any indicators to the charts and now it's up to the user to set the initial options as the library cannot provide any sensible defaults. Many indicators have standard or customary options (for example 20 periods, 2 standard deviations for Bollinger bands) and even if they don't the library could provide safe defaults.

    Anyway, thanks for making a great library!

    opened by mctb32 3
  • 0.9.1 Release

    0.9.1 Release

    Version 0.9.1 has been released. It did not quite get all the features from the 0.9 roadmap, so I'll list what did get done here.

    • Interfaces were added for reference indicators. This gives a simple but slow way to calculate an indicator. It is intended for testing and to help expose bugs.

    • A streaming indicator interface was added. This gives an option to update indicators one bar at a time. It's complicated to support, so most indicators won't support this.

    • Candlestick pattern recognition was added. This should be considered beta, and the interface might change in the future. Documentation is coming soon.

    • DX, ADX, ADXR no longer take close as in input.

    • DX, ADX, ADXR avoid unnecessary NaNs.

    • Fix outputs names for ADX and ADXR (previously was 'dx', now is 'adx' and 'adxr' respectively)

    • Spaces and percent signs were removed from option names for some indicators.

    • Many new indicators were added to a "beta" directory. These need more testing, documentation, and in some cases, still have serious memory bugs.

    • The build process was changed up a bit. tiamalgamation.c will now be checked into the repo, and it's a very easy way to use this library. (i.e. it contains all of the code in one file).

    There were a few other back end changes, a lot of clean up, and I hope this is the start of some good momentum going forward.

    opened by codeplea 0
  • Stochastic RSI cannot be negative

    Stochastic RSI cannot be negative

    Hi @codeplea, I have checked your Stochastic RSI implementation and was wondering why it becomes negative (-0.54) at the end of your "Example Calculation"? From what I have read on Investopedia the Stochastic RSI ranges only between 0 and 1:

    Your tests actually show the same by expecting 0.000 at the end:

    So how come your website lists "-0.54"?

    opened by bennycode 1
  • Polarized Fractal Efficiency indicator

    Polarized Fractal Efficiency indicator

    Polarized Fractal Efficiency (PFE) is a technical indicator that was developed by Hans Hannula to determine price efficiency over a user-defined period. This indicator fluctuates between -100 and +100, with 0 as the centerline. Securities with a PFE greater than zero are deemed to be trending up, while a reading of less than zero indicates the trend is down. Polarized Fractal Efficiency's signature characteristic is its use of fractal geometry in determining how efficiently a security's price is moving.

    A description of the formula is available e.g. here

    opened by jayMcBee 5
TulipCell is an Excel add-in providing 100+ technical analysis indicators.

Tulip Cell Introduction Tulip Cell is an Excel add-in that provides the technical analysis functions from the Tulip Indicators library. Building Build

Tulip Charts LLC 28 Nov 8, 2022
Code accompanying our SIGGRAPH 2021 Technical Communications paper "Transition Motion Tensor: A Data-Driven Approach for Versatile and Controllable Agents in Physically Simulated Environments"

SIGGRAPH ASIA 2021 Technical Communications Transition Motion Tensor: A Data-Driven Framework for Versatile and Controllable Agents in Physically Simu

null 10 Apr 21, 2022
Collection of DLL function export forwards for DLL export function proxying

dll-exports Collection of DLL function export forwards for DLL export function proxying. Typical usecase is for backdooring applications for persisten

Magnus Stubman 58 Dec 6, 2022
C-function for traversing files/directories effectively and calling a given function with each encountered file and a void-pointer as parameters

C-function for traversing files/directories effectively and calling a given function with each encountered file and a void-pointer as parameters

null 1 Jun 27, 2022
DimensionalAnalysis - A compact C++ header-only library providing compile-time dimensional analysis and unit awareness

Dimwits ...or DIMensional analysis With unITS is a C++14 library for compile-time dimensional analysis and unit awareness. Minimal Example #include <i

NJOY 8 Jul 8, 2022
Repository created to store a C function library to use in 42 School

Libft of 42. Make with ❤︎ for Luiz Cezario ?? Index What's this Repo? List of Functions Technologies How to Run Find a Bug? Or somenthing need to chan

Luiz lima cezario 9 Aug 19, 2022
Library for ESP32 to use OV5640's autofocus function

Enable OV5640's autofocus function on ESP32 AI-THINKER Board This library contains the necessary firmware and source code to enable the OV5640 autofoc

Eric 40 Jan 6, 2023
Wave Function Collapse library in C, plus a command-line tool

wfc Single-file Wave Function Collapse library in C, plus a command-line tool License: MIT Version: 0.01 This is an early version that supports the ov

krychu 314 Dec 29, 2022
A recreation of the "Nobelium" malware based on Microsofts Malware analysis - Part 1: PDF2Pwn

Nobelium PdfDownloadRunAesMalware A recreation of the "Nobelium" malware based on Microsofts Malware analysis - Part 1: PDF2Pwn 1. Download PDF file f

boku 94 Nov 9, 2022
Mobile platform for analysis of localization methods using the Intel RealSense T265 sensor

OptiBot Mobile platform for analysis of localization methods using the Intel RealSense T265 sensor About | Content | Implementation | License | Author

Kamil Goś 2 Feb 17, 2022
nanoAOD producer customized for BParking analysis

nanoAOD producer customized for BParking analysis Forked from: The focus is on R($\Lambda_{c}^{(*)}$) anal

Felipe Silva 1 Dec 14, 2021
Dockerfile/docker-compose Elasticsearch with plugins elasticsearch-analysis-vietnamese and coccoc-tokenizer

docker-es-cococ-tokenizer Dockerfile/docker-compose Elasticsearch with plugins elasticsearch-analysis-vietnamese and coccoc-tokenizer Deployment docke

Nguyễn Nhật Minh Tú 7 Nov 8, 2022
SuanPan - 🧮 An Open Source, Parallel and Heterogeneous Finite Element Analysis Framework

suanPan Introduction ?? suanPan is a finite element method (FEM) simulation platform for applications in fields such as solid mechanics and civil/stru

Theodore 22 Dec 27, 2022
Cmake check - Static analysis for CMake files.

cmake_check Cmake_check is a linter for the CMake language. It takes a set of user-defined rules and reports violations for CMakeLists.txt files and C

Dael 21 Dec 10, 2022
Binary data analysis and visualization tool

Veles - A new age tool for binary analysis It is a very difficult task for a human to notice subtle patterns in large amounts of binary data, however,

CodiLime Sp. z o.o. 874 Dec 18, 2022
Model of the classic Ibanez Tube Screamer 808 using Nodal Analysis and WDF with a few new features added!

TS-808-Ultra Model of the classic Ibanez Tube Screamer 808 using Nodal Analysis and WDF with a few new features added! Download Windows vst3 and Mac v

James Stubbs 51 Dec 21, 2022
CVE-2021-4034 POC and Docker and Analysis write up

CVE-2021-4034 POC and Docker and Analysis write up

breeze 9 Oct 22, 2022
Static analysis of structures is a fundamental step for determining the stability of structures

StAnD: A Dataset of Linear Static Analysis Problems [Abstract] [Paper] Static analysis of structures is a fundamental step for determining the stabili

Zuru Tech 3 Jan 4, 2023