Fork me on GitHub

Tulip indicators #

When writing your own strategy you can use all indicators offered by the Tulip Indicators library. Gekko will pass the correct market data to Tulip and you only have to provide the optIn configurable parameters.

Install #

Bash on Windows, OSX or Linux #

Open your terminal. Then:

cd ~/gekko
npm install tulind --no-save

Example #

If you want to use the MACD indicator from Tulip, you need to register it in your strategy like so:

method.init = function() {
  var customMACDSettings = {
    optInFastPeriod: 10,
    optInSlowPeriod: 21,
    optInSignalPeriod: 9
  }

  // add the indicator to the strategy
  this.addTulipIndicator('mymacd', 'macd', customMACDSettings);
}

method.check = function() {
  // use indicator results
  var result = this.tulipIndicators.mymacd.result;
  var macddiff = result['macd'] - result['macdSignal'];

  // do something with macdiff
}

Tulip Indicators #

Here is a list of all supported indicators, click on them to see the required parameters.

API #

ad #

This indicator does not require any parameters.

adosc #

Required parameters:

adx #

More information on the Average Directonal Movement Index

Required parameters:

adxr #

The Average Directional Movement Index Rating is used as a risk indicator for a security in an adx system. It evaluates the risk (volatility) of a security by smoothing the amplitude readings of the trend function of the adx. It is calculated as follows

ADX plus the ADX (n-time periods ago) divided by 2

Higher readings conform to lower risk and lower readings conform to higher risk. A investor wanting to lower the portfolio risk will therefore use securities with higher adxr ratings.

Required parameters:

ao #

More information about the Awesome Oscillator)

This indicator does not require any parameters.

apo #

The Absolute Price Oscillator displays the difference between two exponential moving averages of a security's price and is expressed as an absolute value. It rates the trends strength in relation to the moving between the two moving averages with short-term momentum being the catalyst.

Required parameters:

aroon #

More information about the Aroon Indicator.

Required parameters:

aroonosc #

The Aroon Oscillator belongs to the group of trend-following indicators and uses parts of the Aroon Indicator (namely "Aroon Up" and "Aroon Down") to indicate the strength of a current trend and the likelihood that it will continue. The Aroon Oscillator is calculated by subtracting Aroon Up from Aroon Down. Readings above zero indicate that an uptrend is present, while readings below zero indicate that a downtrend is present.

Required parameters:

atr #

More information about the Average True Range)

Required parameters:

avgprice #

The average price indicator calculates the mean of the open, high, low, and close of a bar

open + high + low + close / 4

This indicator does not require any parameters.

bbands #

More information about Bollinger Bands)

Required parameters:

bop #

The Balance of Power indicator measures the market strength of buyers against sellers by assessing the ability of each side to drive prices to an extreme level. The calculation is:

Balance of Power = (Close price – Open price) / (High price – Low price) 

The resulting value can be smoothed by a moving average.

This indicator does not require any parameters.

cci #

More information about the Commodity Channel Index)

Required parameters:

cmo #

The Chande Momentum Oscillator is a technical momentum indicator. The indicator is created by calculating the difference between the sum of all recent higher closes and the sum of all recent lower closes and then dividing the result by the sum of all price movement over a given time period. The result is multiplied by 100 to give the -100 to +100 range. The defined time period is usually 20 periods.

CMO = 100 * ((Sh - Sd)/ ( Sh + Sd ) )

Where:

Sh = Sum of the difference between the current close and previous close on up days for the specified period. Up days are days when the current close is greater than the previous close.

Sd = Sum of the absolute value of the difference between the current close and the previous close on down days for the specified period. Down days are days when the current close is less than the previous close.

Required parameters:

cvi #

More information about the Chaikin Volatility Index also called the Chaikin Oscillator.

Required parameters:

dema #

More information about the DEMA

Required parameters:

di #

More information about the Directional Indicator

Required parameters:

dm #

More information about the Directional Movement Index

Required parameters:

dpo #

More information about the Detrended Price Oscillator

Required parameters:

dx #

More information about the Directional Movement Index

Required parameters:

ema #

Exponential Moving Average (EMA) is similar to Simple Moving Average (SMA), measuring trend direction over a period of time. However, whereas SMA simply calculates an average of price data, EMA applies more weight to data that is more current. Because of its unique calculation, EMA will follow prices more closely than a corresponding SMA.

EMA = (K x (C - P)) + P

Where:

Required parameters:

emv #

More information about the Ease of Movement)

This indicator does not require any parameters.

fisher #

The Fisher Transform is a technical indicator that converts prices into a Gaussian normal distribution. The indicator enables traders to create a nearly Gaussian probability density function by normalizing prices. That is, the transformation makes peak swings relatively rare events and unambiguously identifies price reversals on a chart.

Y = 0.5 * ln ((1+X)/(1-X))

Where:

Required parameters:

fosc #

The forecast oscillator attempts to predict price action by comparing the results of a linear regression trendline to the actual price for that day. Positive values of the oscillator occur when the forecast price is above the actual price and negative values when the forecast price is below. If prices are consistently below the forecast, then a downturn in prices is likely. Conversely, if prices are consistently above the forecast then an upturn in prices is likely.

Required parameters:

hma #

Basic forms of moving averages like the Simple Moving Average lag price. The Exponential and Weighted Moving Averages were developed to address this lag by placing more emphasis on more recent data. The Hull Moving Average in contrast is an extremely fast and smooth moving average, it almost eliminates lag altogether and manages to improve smoothing at the same time.

HMA= WMA(2*WMA(n/2) − WMA(n)),sqrt(n))

Required parameters:

kama #

The Kaufman adaptive moving average belongs to the group of "intelligent" indicators. It´s concept addresses the fact that noisy markets should have a lagging indicator and trending markets should have a leading indicator. So it adapts itself to lag in sideways markets and lead in trending markets.

KAMA(t) = KAMA(t-1) + sc(t) x (Price-KAMA(t-1))

Where:

Required parameters:

kvo #

The Klinger Volume Oscillator measures trends of money flows based upon volume. The KO is derived from three types of data: the high-low price range, volume, and accumulation/distribution. Price range is a measure of movement and the force behind that movement is volume. Accumulation is when the sum of today's [high]+[low]+[close] is greater than yesterday's. Distribution is when today's sum is less than the yesterday's. When the sums are equal, the existing trend is maintained.

Required parameters:

linreg #

The Linear Regression is a smoothing functions that works by preforming linear least squares regression over a moving window. It then uses the linear model to predict the value for the current bar.

Required parameters:

linregintercept #

More information about the Linear Regression Intercept

Required parameters:

linregslope #

More information about the Linear Regression Intercept

Required parameters:

macd #

More information about the MACD)

Required parameters:

marketfi #

The Market Facilitation Index indicator combines price and volume in the analysis to establish the effectiveness of price movement by computing the price movement per volume unit. To calculate the Market Facilitation Index indicator the difference between the low and the high price are taken and divided by the volume.

This indicator does not require any parameters.

mass #

The Mass Index indicator is used for finding trend reversals, based on the premise that reversals are likely to happen when the price range widens. It does not have a directional bias. The calculation, which compares the previous trading ranges (highs minus lows), uses Exponential Moving Averages (EMA). If there is substantial movement, the Mass Index Indicator increases if there is insubstantial movement the Mass Index Indicator decreases.

Formula (usually a 9 period EMA is used)

Single EMA = (x)-period exponential moving average (EMA) of the high-low differential  
Double EMA = (y)-period EMA of the (x)-period EMA of the high-low differential 
EMA Ratio = Single EMA divided by Double EMA 
Mass Index = 25-period sum of the EMA Ratio 

Required parameters:

medprice #

The median price indicator calculates the mean of the high and low for a bar. Despite the name, it does not calculate an actual median value.

medprice(t) = (high(t) + low(t)) / 2

This indicator does not require any parameters.

mfi #

More information about the MFI)

Required parameters:

msw #

The Maximum Entropy Spectrum Analysis indicator is a unique way to accurately measure short-term cycles in a market. It utilizes two sine plots to illustrate if the market is in a cycle mode or in a trend mode. When the two plots resemble a sine wave the market is in cycling mode. When the plots start to wander the market is in a trend mode. The MESA Sine Wave indicator is a leading indicator that will anticipate cycle mode turning points rather than waiting for confirmation as is seen with most other oscillators. The indicator has the additional advantage that trend mode whipsaw signals are minimized.

Required parameters:

natr #

The Normalized Average True Range is a measure of volatility. It is calculated as follows:

natr = (atr(t) / close(t)) * 100

Required parameters:

nvi #

More information about the NVI

This indicator does not require any parameters.

obv #

More information about the OBV)

This indicator does not require any parameters.

ppo #

More information about the PPO)

Required parameters:

psar #

More information about the Parabolic SAR)

Required parameters:

pvi #

More information about the PVI

This indicator does not require any parameters.

qstick #

The Qstick Indicator identifies trends on a chart. It is calculated by taking an 'n' period moving average of the difference between the open and closing prices. A Qstick value greater than zero means that the majority of the last 'n' days have been up, indicating that buying pressure has been increasing. In summary, the measure provides an approximation for a security’s EMA, opening price, closing price, and their difference, as well as these values SMA.

Required parameters:

roc #

More information about the Rate of Change)

Required parameters:

rocr #

Rate Of Change Ratio calculates the change between the current price and the price n bars ago.

Required parameters:

rsi #

More information about the RSI)

Required parameters:

sma #

More information about the SMA

Required parameters:

stoch #

More information about the STOCH)

Required parameters:

sum #

The Sum Over Period indicator simply returns the sum of the last n bars.

Required parameters:

tema #

The Triple Exponential Moving Average is similar to the Exponential Moving Average or the Double Exponential Moving Average, but provides even less lag. Triple Exponential Moving Average is probably best viewed as an extension of Double Exponential Moving Average.

It can be expressed in terms of the Exponential Moving Average as follows:

tema = 3 * ema(in) - 3 * ema(ema(in)) + ema(ema(ema(in)))

Required parameters:

tr #

True range is a measure of volatility. It represents how much a security changed price on a given day.

True range for each day is the greatest of:

This indicator does not require any parameters.

trima #

The Triangular Moving Average is similar to the Simple Moving Average but instead places more weight on middle portion of the smoothing period and less weight on the newest and oldest bars in the period. It is calculated for each bar as the weighted arithmetic mean of the previous n bars. For example, the weights w for an n of 4 are: 1, 2, 2, 1. The weights w for a n of 7 are: 1, 2, 3, 4, 3, 2, 1. It's easy to see why it's called the Triangular Moving Average.

Required parameters:

trix #

More information about the TRIX

Required parameters:

tsf #

The Time Series Forecast indicator displays the statistical trend of a security's price over a specified time period. The trend is based on linear regression analysis. Rather than plotting a straight linear regression trendline, the Time Series Forecast plots the last point of multiple linear regression trendlines. The resulting TSF indicator is sometimes referred to as the "moving linear regression" indicator or the "regression oscillator."

Required parameters:

typprice #

The Typical Price calculates the arithmetic mean of the high, low, and close of a bar.

This indicator does not require any parameters.

ultosc #

More information about the UO)

Required parameters:

vhf #

The Vertical Horizontal Filter determines whether prices are in a trending phase or a congestion phase. It is used to dertermine which other indicators are to be used in the current market trend. For example if the VHF suggests the market is in a range then a [mesa] could be used if the VHF suggests the market is in a range then one could use a [psar] to determine entry and exit points.

Required parameters:

vidya #

The Variable Index Dynamic Average indicator modifies the Exponential Moving Average by varying the smoothness based on recent volatility.

Required parameters:

volatility #

The Annualized Historical Volatility indicator calculates the volatility over a moving window.

Required parameters:

vosc #

The Volume Oscillator identifies trends in volume using two moving averages of volume, one fast and one slow. The fast volume moving average is then subtracted from the slow moving average.

Required parameters:

vwma #

The Volume Weighted Moving Average is simalair to a Simple Moving Average, but it weights each bar by its volume.

Required parameters:

wad #

Williams AD is a running sum of positive accumulation values (buying pressure) and negative distribution values (selling pressure), as determined by price's location within a given day's true range. The day's accumulation/distribution is then calculated by comparing today's closing price to yesterday's closing price. To calculate the Williams' Accumulation/Distribution indicator, determine:

True Range High (TRH) = Yesterday's close or today's high whichever is greater
True Range Low (TRL) = Yesterday's close or today's low whichever is less

The Williams' Accumulation/Distribution indicator is a cumulative total of the daily values:

This indicator does not require any parameters.

wcprice #

The weighted close price indicator calculates the mean of the high, low, and close of a bar, but the close price is weighted to count for double.

This indicator does not require any parameters.

wilders #

The Welles Wilder Smoothing indicator is basically the same as an EMA and can be used in the same manner. It uses a different calculation but can be easily calculated by simply converting EMA values as follows:

wilders = (ema + 1) / 2

Required parameters:

willr #

More information about the Williams R)

Required parameters:

wma #

More information about the WMA

Required parameters:

zlema #

Zero-Lag Exponential Moving Average modifies a Exponential Moving Average to greatly reduce lag.

Required parameters: