first commit
This commit is contained in:
commit
aa7869eb33
386 files changed
+69375
No files matched your search
@@ -0,0 +1,199 @@
|
||||
# Creating a strategy
|
||||
|
||||
*Have you made your own strategy? Gekko Plus is hosting an official Strategy contest: submit your strategy and have a change to win 0.1 BTC! Read more details on [Gekko Plus](https://app.gekkoplus.com/contest).*
|
||||
|
||||
Strategies are the core of Gekko's trading bot. They look at the market and decide what to do based on technical analysis indicators. A single strategy is limited to a single market on a single exchange.
|
||||
|
||||
Gekko currently comes with [a couple of strategies](./introduction.md) out of the box. Besides those you can also write your own strategy in javascript. If you want to understand how to create your own strategy you can watch this video or read the tech docs on this page.
|
||||
|
||||
[](https://www.youtube.com/watch?v=6-74ZhrG0BE)
|
||||
|
||||
A strategy is a module with a few functions that get market data in the form of candles ([OHLC](https://en.wikipedia.org/wiki/Open-high-low-close_chart), volume, and the average weighted price) and output trading advice.
|
||||
|
||||
## Strategy boilerplate
|
||||
|
||||
// Let's create our own strategy
|
||||
var strat = {};
|
||||
|
||||
// Prepare everything our strat needs
|
||||
strat.init = function() {
|
||||
// your code!
|
||||
}
|
||||
|
||||
// What happens on every new candle?
|
||||
strat.update = function(candle) {
|
||||
// your code!
|
||||
}
|
||||
|
||||
// For debugging purposes.
|
||||
strat.log = function() {
|
||||
// your code!
|
||||
}
|
||||
|
||||
// Based on the newly calculated
|
||||
// information, check if we should
|
||||
// update or not.
|
||||
strat.check = function(candle) {
|
||||
// your code!
|
||||
}
|
||||
|
||||
// Optional for executing code
|
||||
// after completion of a backtest.
|
||||
// This block will not execute in
|
||||
// live use as a live gekko is
|
||||
// never ending.
|
||||
strat.end = function() {
|
||||
// your code!
|
||||
}
|
||||
|
||||
module.exports = strat;
|
||||
|
||||
# Strategy lifecycle methods
|
||||
|
||||
The above boilerplate contains four functions. These functions are executed by Gekko like so:
|
||||
|
||||
- When Gekko starts: run init.
|
||||
- On each new candle:
|
||||
- run [update](#update-function)
|
||||
- once the strategy has completed warmup:
|
||||
- run [log](#log-function)
|
||||
- run [check](#check-function)
|
||||
|
||||
### init function
|
||||
|
||||
Executed when the trading strategy starts. Your strategy can initialize state and [register indicators](#Indicators).
|
||||
|
||||
### update function
|
||||
|
||||
This function executes on every new candle. You can access the latest candle as the first (and only) parameter (it's also stored in `this.candle`).
|
||||
|
||||
### log function
|
||||
|
||||
The log function is executed on every new candle when the `debug` flag is on (always off when running in the UI, as configured in [the config](../commandline/about_the_commandline.md) for CLI gekkos). Logging is used to log certain state from the strategy and can be used to debug your strategy to get more insights in why it took certain decisions.
|
||||
|
||||
### check function
|
||||
|
||||
Most strategies need to warmup before the trading strategy can be started. For example the strategy may be calculating a moving average for the first 3 candles, as such it must have at least 3 candles to output a number the strategy logic relies on. The check function is executed after the warmup period is over. The default required history is 0. You can set it like so in your init function:
|
||||
|
||||
this.requiredHistory = 5; // require 5 candles before giving advice
|
||||
|
||||
If you find out in the check function that you want to give new advice to the trader you can use the advice function:
|
||||
|
||||
this.advice({
|
||||
direction: 'long', // or short
|
||||
trigger: { // ignored when direction is not "long"
|
||||
type: 'trailingStop',
|
||||
trailPercentage: 5
|
||||
// or:
|
||||
// trailValue: 100
|
||||
}
|
||||
});
|
||||
|
||||
The trigger is optional, if the direction is long and the trigger is specified as a trailingStop this will request the trader to create a trail stop trigger.
|
||||
|
||||
### candle variable
|
||||
|
||||
The following list of candle variables will be available when writing strategies, they are part of the candle object which is given to your `update` and `check` functions (it's also accessable through `this.candle`).
|
||||
|
||||
- candle.close: the closing price of the candle
|
||||
- candle.high: the highest price of the candle
|
||||
- candle.low: the lowest price of the candle
|
||||
- candle.volume: the trading volume of that candle
|
||||
- candle.trades: number of trades in that candle
|
||||
|
||||
## Things to keep in mind
|
||||
|
||||
- You can activate your own strategy by setting `config.tradingAdvisor.strategy` to `custom` (or whatever you named your file inside the `gekko/strategies`) in the loaded config.
|
||||
- Gekko will execute the `update` function for every new candle. A candle is the size in minutes configured at `config.tradingAdvisor.candleSize` in the loaded config.
|
||||
- It is advised to set history `config.tradingAdvisor.historySize` the same as the requiredHistory as Gekko will use this property to create an initial batch of candles.
|
||||
- Never rely on anything based on system time because each method can run on live markets as well as during backtesting. You can look at the `candle.start` property which is a `moment` object of the time the candles started.
|
||||
|
||||
## Strategy tools
|
||||
|
||||
To help you Gekko has a number of strategy tools.
|
||||
|
||||
### Indicators
|
||||
|
||||
Gekko supports a few indicators natively, in addition to the integration of indicators from the library [TA-lib](http://ta-lib.org/).
|
||||
|
||||
#### Example usage
|
||||
|
||||
If you want to use an indicator you can add it in the `init` function and Gekko will handle the updating for you on every candle (before the update and before the check call):
|
||||
|
||||
// add a native indicator
|
||||
this.addIndicator('name', 'type', parameters);
|
||||
|
||||
or
|
||||
|
||||
// add a TA-lib indicator
|
||||
this.addTalibIndicator('name', 'type', parameters);
|
||||
|
||||
or
|
||||
|
||||
// add a Tulip indicator
|
||||
this.addTulipIndicator('name', 'type', parameters);
|
||||
|
||||
The first parameter is the name, the second is the indicator type you want and the third is an object with all indicator parameters. If you want an MACD indicator you can do it like so:
|
||||
|
||||
In your init function:
|
||||
|
||||
// add a native indicator
|
||||
var parameters = {short: 10, long: 20, signal: 9};
|
||||
this.addIndicator('mynativemacd', 'MACD', parameters);
|
||||
|
||||
// add a TA-lib indicator
|
||||
var parameters = {optInFastPeriod: 10, optInSlowPeriod: 21, optInSignalPeriod: 9};
|
||||
this.addTalibIndicator('mytalibmacd', 'macd', parameters);
|
||||
|
||||
// add a Tulip indicator
|
||||
var parameters = {optInFastPeriod: 10, optInSlowPeriod: 21, optInSignalPeriod: 9};
|
||||
this.addTulipIndicator('mytulipmacd', 'macd', parameters);
|
||||
|
||||
In your check or update function:
|
||||
|
||||
var result = this.indicators.mytalibmacd.result;
|
||||
|
||||
See the [TA-lib indicators](./talib_indicators.md) document for a list of all supported TA-lib indicators and their required parameters.
|
||||
|
||||
See the [Tulip indicators](./tulip_indicators.md) document for a list of all supported Tulip indicators and their required parameters.
|
||||
|
||||
### Strategy parameters
|
||||
|
||||
Adjust strategy execution by creating custom strategy parameters. This way the same strategy can execute strategies concurrently using different parameters for different markets. For example the MACD strategy has parameters concerning the underlying MACD indicator (such as values for the LONG and SHORT EMAs). Create custom configuration settings in the `config/strategies` directory:
|
||||
|
||||
// custom settings:
|
||||
config.custom = {
|
||||
my_custom_setting: 10,
|
||||
};
|
||||
|
||||
Retrieve them in your strategy like this:
|
||||
|
||||
// anywhere in your code:
|
||||
log.debug(this.settings.my_custom_setting); // Logs 10
|
||||
|
||||
___Note that the name of your configuration must be the same as the name of the strategy___
|
||||
|
||||
### External libraries
|
||||
|
||||
Gekko uses a few general purpose libraries internally. The API from those libraries are available to you as well. Most notable libraries are [lodash](http://lodash.com/) (similar as underscore) and [async](https://github.com/caolan/async).
|
||||
|
||||
You can load them like so:
|
||||
|
||||
// before any other code
|
||||
var _ = require('lodash');
|
||||
var async = require('async');
|
||||
|
||||
### Logging
|
||||
|
||||
Gekko has a small logger you can use (preferably in your log function):
|
||||
|
||||
// before any other code
|
||||
var log = require('../core/log.js');
|
||||
|
||||
// in your log function
|
||||
log.debug('hello world');
|
||||
|
||||
|
||||
-----
|
||||
|
||||
Take a look at the existing methods, if you have questions feel free to create an issue. If you created your own awesome strategies and want to share it with the world feel free to contribute it to gekko.
|
||||
@@ -0,0 +1,122 @@
|
||||
# Gekko indicators
|
||||
|
||||
When [creating your own strategy](./creating_a_strategy.md) there are a few built in indicators you can use that ship with Gekko.
|
||||
|
||||
## Example
|
||||
|
||||
If you want to use the MACD indicator from Gekko, you need to register it in your strategy like so:
|
||||
|
||||
method.init = function() {
|
||||
var settings = {
|
||||
short: 10,
|
||||
long: 21,
|
||||
signal: 9
|
||||
};
|
||||
|
||||
// add the indicator to the strategy
|
||||
this.addIndicator('mymacd', 'MACD', settings);
|
||||
}
|
||||
|
||||
method.check = function() {
|
||||
// use indicator results
|
||||
var macdiff = this.indicators.mymacd.result;
|
||||
|
||||
// do something with macdiff
|
||||
}
|
||||
|
||||
## Indicators
|
||||
|
||||
Here is a list of all supported indicators, click on them to read more about what they are and how to implement them in Gekko:
|
||||
|
||||
- [EMA](#EMA)
|
||||
- [PPO](#PPO)
|
||||
- [CCI](#CCI)
|
||||
- [DEMA](#DEMA)
|
||||
- [LRC](#LRC)
|
||||
- [MACD](#MACD)
|
||||
- [RSI](#RSI)
|
||||
- [SMA](#SMA)
|
||||
- [TSI](#TSI)
|
||||
- [UO](#UO)
|
||||
|
||||
### EMA
|
||||
|
||||
> **What is an 'Exponential Moving Average - EMA'**
|
||||
> "An exponential moving average (EMA) is a type of moving average that is similar to a simple moving average, except that more weight is given to the latest data. It's also known as the exponentially weighted moving average. This type of moving average reacts faster to recent price changes than a simple moving average."
|
||||
|
||||
*[More info on investopedia](http://www.investopedia.com/terms/e/ema.asp).*
|
||||
|
||||
You can implement the EMA like so:
|
||||
|
||||
method.init = function() {
|
||||
var weight = 10;
|
||||
|
||||
// add the indicator to the strategy
|
||||
this.addIndicator('myema', 'EMA', weight);
|
||||
}
|
||||
|
||||
method.check = function() {
|
||||
// use indicator results
|
||||
var ema = this.indicators.myema.result;
|
||||
|
||||
// do something with macdiff
|
||||
}
|
||||
|
||||
|
||||
### PPO
|
||||
> **What is the 'Percentage Price Oscillator - PPO'**
|
||||
> "The percentage price oscillator (PPO) is a technical momentum indicator showing the relationship between two moving averages."
|
||||
|
||||
*[More info on investopedia](https://www.investopedia.com/terms/p/ppo.asp).*
|
||||
|
||||
### CCI
|
||||
> **What is the 'Commodity Channel Index - CCI'**
|
||||
> "The Commodity Channel Index (CCI) is a momentum based technical trading tool used most often to help determine when an investment vehicle is reaching a condition of being overbought or oversold."
|
||||
|
||||
*[More info on investopedia](https://www.investopedia.com/terms/c/commoditychannelindex.asp).*
|
||||
|
||||
### DEMA
|
||||
|
||||
> **What is the 'Double Exponential Moving Average - DEMA'**
|
||||
> "The DEMA is a fast-acting moving average that is more responsive to market changes than a traditional moving average. It was developed in an attempt to create a calculation that eliminated some of the lag associated with traditional moving averages."
|
||||
|
||||
*[More info on investopedia](https://www.investopedia.com/terms/d/double-exponential-moving-average.asp).*
|
||||
|
||||
### LRC
|
||||
|
||||
> **What is the 'Linear Regression Channel - LRC'**
|
||||
> "This indicator plots a line that best fits the prices specified over a user-defined time period. The Linear Regression Curve is used mainly to identify trend direction and is sometimes used to generate buy and sell signals."
|
||||
|
||||
*[More info on Interactive Brokers](https://www.interactivebrokers.co.uk/en/software/tws/usersguidebook/technicalanalytics/linearregressioncurve.htm).*
|
||||
|
||||
### MACD
|
||||
> **What is the 'Moving Average Convergence Divergence - MACD'**
|
||||
> "Moving average convergence divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages of prices."
|
||||
|
||||
*[More info on investopedia](https://www.investopedia.com/terms/m/macd.asp).*
|
||||
|
||||
### RSI
|
||||
> **What is the 'Relative Strength Index - RSI'**
|
||||
> "Compares the magnitude of recent gains and losses over a specified time period to measure speed and change of price movements of a security. It is primarily used to attempt to identify overbought or oversold conditions in the trading of an asset."
|
||||
|
||||
*[More info on investopedia](https://www.investopedia.com/terms/r/rsi.asp).*
|
||||
|
||||
### SMA
|
||||
> **What is the 'Simple Moving Average - SMA'**
|
||||
> "A simple moving average (SMA) is an arithmetic moving average calculated by adding the closing price of the security for a number of time periods and then dividing this total by the number of time periods."
|
||||
|
||||
*[More info on investopedia](https://www.investopedia.com/terms/s/sma.asp).*
|
||||
|
||||
### TSI
|
||||
|
||||
> **What is the 'True Strength Index - TSI'**
|
||||
> "A technical momentum indicator that helps traders determine overbought and oversold conditions of a security by incorporating the short-term purchasing momentum of the market with the lagging benefits of moving averages."
|
||||
|
||||
*[More info on investopedia](https://www.investopedia.com/terms/t/tsi.asp).*
|
||||
|
||||
### UO
|
||||
|
||||
> **What is the 'Ultimate Oscillator - UO'**
|
||||
> "A technical indicator that uses the weighted average of three different time periods to reduce the volatility and false transaction signals that are associated with many other indicators that mainly rely on a single time period"
|
||||
|
||||
*[More info on investopedia](https://www.investopedia.com/terms/u/ultimateoscillator.asp).*
|
||||
@@ -0,0 +1,193 @@
|
||||
# Gekko Strategies
|
||||
|
||||
Gekko uses [technical analysis indicators](http://www.investopedia.com/articles/active-trading/102914/technical-analysis-strategies-beginners.asp) inside **strategies**.
|
||||
|
||||
This investment advice is going to be either **long** or **short**. Long indicates that Gekko the asset should be bought and short indicates that it should be sold.
|
||||
|
||||
If you are familiar with javascript you can easily create your own strategies. Here is a video explaining everything you need to know:
|
||||
|
||||
[](https://www.youtube.com/watch?v=6-74ZhrG0BE)
|
||||
|
||||
Below you can find simple and exemplary strategies that come with Gekko. These strategies come with Gekko and serve as examples.
|
||||
|
||||
Gekko currently comes with the following example strategies:
|
||||
|
||||
- [DEMA](#DEMA)
|
||||
- [MACD](#MACD)
|
||||
- [PPO](#PPO)
|
||||
- [RSI](#RSI)
|
||||
- [StochRSI](#StochRSI)
|
||||
- [CCI](#CCI)
|
||||
- [talib-macd](#talib-macd)
|
||||
- [tulip-macd](#tulip-macd)
|
||||
|
||||
### DEMA
|
||||
|
||||
This strategy uses `Exponential Moving Average crossovers` to determine the current trend the
|
||||
market is in. Using this information it will suggest to ride the trend. Note that this is
|
||||
not MACD because it just checks whether the longEMA and shortEMA are [threshold]% removed
|
||||
from each other.
|
||||
|
||||
This strategy is fairly popular in bitcoin trading due to Bitcointalk user Goomboo. Read more about this strategy in [his topic](https://bitcointalk.org/index.php?topic=60501.0) or [here](http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages).
|
||||
|
||||
You can configure the following parameters:
|
||||
|
||||
# EMA weight (α)
|
||||
# the higher the weight, the more smooth (and delayed) the line
|
||||
short = 10
|
||||
long = 21
|
||||
|
||||
[thresholds]
|
||||
down = -0.025
|
||||
up = 0.025
|
||||
|
||||
- short is the short EMA that moves closer to the real market (including noise)
|
||||
- long is the long EMA that lags behind the market more but is also more resistant to noise.
|
||||
- the down threshold and the up threshold tell Gekko how big the difference in the lines needs to be for it to be considered a trend. If you set these to 0 each line cross would trigger new advice.
|
||||
|
||||
### MACD
|
||||
|
||||
The MACD is one of the most popular trend watching **indicators** in finance, it was created by Gerald Appel in the late 1970s. By using multiple price averages (EMAs) of different periods (one that follows the market more closely and one that lags behind, only catching bigger price swings). The indicator itself ouputs multiple numbers, when comparing them they can be interepted as signals that show when the trend of the price is changing.
|
||||
|
||||
The MACD **strategy** in Gekko is a simple strategy that implements the indicator. By comparing the difference between the EMAs from the signal the strategy triggers buy and sell signals. The strategy does come with additional logic:
|
||||
|
||||
- **thresholds**: a signal will be triggered as soon as the difference goes above or below a configurable threshold, making the strategy more flexible than simply checking if the difference is above or below zero. If you set these to 0 each line cross would trigger new advice.
|
||||
- **persistance**: instead of trading as soon the difference is above or below the threshold, the strategy will wait a few candles to see if the difference keeps persisting. Only if it does the strategy will actually signal to Gekko to buy or sell. By setting persistance to 0 this behaviour is disabled.
|
||||
- **short** is the short EMA that moves closer to the real market (including noise)
|
||||
- **long** is the long EMA that lags behind the market more but is also more resistant to noise.
|
||||
- **signal** is the EMA weight calculated over the difference from short/long.
|
||||
|
||||
Read more about it [here](http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_average_convergence_divergence_macd).
|
||||
|
||||
You can configure the following parameters:
|
||||
|
||||
# EMA weight (α)
|
||||
# the higher the weight, the more smooth (and delayed) the line
|
||||
short = 10
|
||||
long = 21
|
||||
signal = 9
|
||||
|
||||
# the difference between the EMAs (to act as triggers)
|
||||
[thresholds]
|
||||
down = -0.025
|
||||
up = 0.025
|
||||
# How many candle intervals should a trend persist
|
||||
# before we consider it real?
|
||||
persistence = 1
|
||||
|
||||
### PPO
|
||||
|
||||
Very similar to MACD but also a little different, read more [here](http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:price_oscillators_ppo).
|
||||
|
||||
You can configure the following parameters:
|
||||
|
||||
# EMA weight (α)
|
||||
# the higher the weight, the more smooth (and delayed) the line
|
||||
short = 12
|
||||
long = 26
|
||||
signal = 9
|
||||
|
||||
# the difference between the EMAs (to act as triggers)
|
||||
[thresholds]
|
||||
down = -0.025
|
||||
up = 0.025
|
||||
# How many candle intervals should a trend persist
|
||||
# before we consider it real?
|
||||
persistence = 2
|
||||
|
||||
- short is the short EMA that moves closer to the real market (including noise)
|
||||
- long is the long EMA that lags behind the market more but is also more resistant to noise.
|
||||
- signal is the EMA weight calculated over the difference from short/long.
|
||||
- the down threshold and the up threshold tell Gekko how big the difference in the lines needs to be for it to be considered a trend. If you set these to 0 each line cross would trigger new advice.
|
||||
- persistence tells Gekko how long the thresholds needs to be met until Gekko considers the trend to be valid.
|
||||
|
||||
### RSI
|
||||
|
||||
The RSI indicator is and old but ever popular trend watching **indicator**, introduced in 1978 by J. Welles Wilder this simple indicator has never stopped to be a popular tool for traders. In its essence RSI follows a simple formula to measure the speed by which the price is changing. When the price keeps going up at an accelarating rate the market might be overbought and a reversal might come next.
|
||||
|
||||
The RSI **strategy** in Gekko is a simple strategy that implements the RSI indicator. By calculating the RSI as the market develops this strategy can trigger buy or sell signals based on the RSI going too high (overbought) or too low (oversold). The strategy does come with additional logic:
|
||||
|
||||
- **interval** is the amount of periods the RSI should use.
|
||||
- **thresholds** determine what level of RSI would trigger an up or downtrend.
|
||||
- **persistance**: instead of trading as soon the difference is above or below the threshold, the strategy will wait a few candles to see if the difference keeps persisting. Only if it does the strategy will actually signal to Gekko to buy or sell. By setting persistance to 0 this behaviour is disabled.
|
||||
|
||||
Read more about it [here](http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:relative_strength_index_rsi).
|
||||
|
||||
You can configure the following parameters:
|
||||
|
||||
interval = 14
|
||||
|
||||
[thresholds]
|
||||
low = 30
|
||||
high = 70
|
||||
# How many candle intervals should a trend persist
|
||||
# before we consider it real?
|
||||
persistence = 2
|
||||
|
||||
### StochRSI
|
||||
|
||||
The StochRSI indicator uses an RSI indicator at its core and as such is similar to the RSI strategy that uses this indicator. The difference is that after the RSI is calculated a stochastic oscillator is calculated over the resulting RSI values. When a market is trending upwards for a long time the RSI values tend to go and stay high. The stochastic oscillator will compare the RSI values from the last period with eachother. This results in the StochRSI indicator therefor indicate how high or low the RSI values have been historically over the last n periods.
|
||||
|
||||
The StochRSI **strategy** in Gekko is a simple strategy that implements the StochRSI indicator. By calculating the StochRSI as the market develops this strategy can trigger buy or sell signals based on the signal going too high (overbought) or too low (oversold). The strategy does come with configurables:
|
||||
|
||||
- **interval**: This setting defines both the RSI interval used to calculate the RSI values as well as the historical period used by the stochastic oscillator to compare RSI values with.
|
||||
- **persistance**: instead of trading as soon the difference is above or below the threshold, the strategy will wait a few candles to see if the difference keeps persisting. Only if it does the strategy will actually signal to Gekko to buy or sell. By setting persistance to 0 this behaviour is disabled.
|
||||
- **thresholds**: The high and low thresholds are defined as numbers between 1 and 100. Different from StochRSI in other trading systems, this number indicates a percentage instead of a fraction of 1.
|
||||
|
||||
You can configure the following parameters:
|
||||
|
||||
interval = 3
|
||||
|
||||
[thresholds]
|
||||
low = 20
|
||||
high = 80
|
||||
persistence = 3
|
||||
|
||||
### CCI
|
||||
|
||||
You can configure the following parameters:
|
||||
|
||||
# constant multiplier. 0.015 gets to around 70% fit
|
||||
constant = 0.015
|
||||
|
||||
# history size, make same or smaller than history
|
||||
history = 90
|
||||
|
||||
[thresholds]
|
||||
up = 100
|
||||
down = -100
|
||||
persistence = 0
|
||||
|
||||
[TODO!]
|
||||
|
||||
### talib-macd
|
||||
|
||||
Similar to the default MACD strategy, this showcases how to add a TA-lib indicator to a strategy.
|
||||
|
||||
You can configure the following parameters:
|
||||
|
||||
[parameters]
|
||||
optInFastPeriod = 10
|
||||
optInSlowPeriod = 21
|
||||
optInSignalPeriod = 9
|
||||
|
||||
[thresholds]
|
||||
down = -0.025
|
||||
up = 0.025
|
||||
|
||||
### tulip-macd
|
||||
|
||||
Similar to the default MACD strategy, this showcases how to add a Tulip indicator to a strategy.
|
||||
|
||||
You can configure the following parameters:
|
||||
|
||||
[parameters]
|
||||
optInFastPeriod = 10
|
||||
optInSlowPeriod = 21
|
||||
optInSignalPeriod = 9
|
||||
|
||||
[thresholds]
|
||||
down = -0.025
|
||||
up = 0.025
|
||||
|
||||
[TODO!]
|
||||
@@ -0,0 +1,609 @@
|
||||
# TA-lib indicators
|
||||
|
||||
When writing [your own strategy](./creating_a_strategy.md) you can use all indicators offered by [the TA-lib library](http://ta-lib.org/function.html). Gekko will pass the correct market data to TA-lib 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 talib --no-save
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
If you want to use the MACD indicator from TA-lib, 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.addTalibIndicator('mymacd', 'macd', customMACDSettings);
|
||||
}
|
||||
|
||||
method.check = function() {
|
||||
// use indicator results
|
||||
var result = this.talibIndicators.mymacd.result;
|
||||
var macddiff = result['outMACD'] - result['outMACDSignal'];
|
||||
|
||||
// do something with macdiff
|
||||
}
|
||||
|
||||
## TA-lib Indicators
|
||||
|
||||
Here is a list of all supported indicators, click on them to see the required parameters.
|
||||
|
||||
- [ACCBANDS](#accbands)
|
||||
- [AD](#ad)
|
||||
- [ADOSC](#adosc)
|
||||
- [ADX](#adx)
|
||||
- [ADXR](#adxr)
|
||||
- [APO](#apo)
|
||||
- [AROON](#aroon)
|
||||
- [AROONOSC](#aroonosc)
|
||||
- [ATR](#atr)
|
||||
- [AVGPRICE](#avgprice)
|
||||
- [BBANDS](#bbands)
|
||||
- [BOP](#bop)
|
||||
- [CCI](#cci)
|
||||
- [CMO](#cmo)
|
||||
- [DEMA](#dema)
|
||||
- [DX](#dx)
|
||||
- [EMA](#ema)
|
||||
- [HT_DCPERIOD](#ht_dcperiod)
|
||||
- [HT_DCPHASE](#ht_dcphase)
|
||||
- [HT_PHASOR](#ht_phasor)
|
||||
- [HT_SINE](#ht_sine)
|
||||
- [HT_TRENDLINE](#ht_trendline)
|
||||
- [HT_TRENDMODE](#ht_trendmode)
|
||||
- [IMI](#imi)
|
||||
- [KAMA](#kama)
|
||||
- [LINEARREG](#linearreg)
|
||||
- [LINEARREG_ANGLE](#linearreg_angle)
|
||||
- [LINEARREG_INTERCEPT](#linearreg_intercept)
|
||||
- [LINEARREG_SLOPE](#linearreg_slope)
|
||||
- [MA](#ma)
|
||||
- [MACD](#macd)
|
||||
- [MACDEXT](#macdext)
|
||||
- [MACDFIX](#macdfix)
|
||||
- [MAMA](#mama)
|
||||
- [MAVP](#mavp)
|
||||
- [MAX](#max)
|
||||
- [MAXINDEX](#maxindex)
|
||||
- [MEDPRICE](#medprice)
|
||||
- [MFI](#mfi)
|
||||
- [MIDPOINT](#midpoint)
|
||||
- [MIDPRICE](#midprice)
|
||||
- [MIN](#min)
|
||||
- [MININDEX](#minindex)
|
||||
- [MINMAX](#minmax)
|
||||
- [MINMAXINDEX](#minmaxindex)
|
||||
- [MINUS_DI](#minus_di)
|
||||
- [MINUS_DM](#minus_dm)
|
||||
- [MOM](#mom)
|
||||
- [NATR](#natr)
|
||||
- [OBV](#obv)
|
||||
- [PLUS_DI](#plus_di)
|
||||
- [PLUS_DM](#plus_dm)
|
||||
- [PPO](#ppo)
|
||||
- [ROC](#roc)
|
||||
- [ROCP](#rocp)
|
||||
- [ROCR](#rocr)
|
||||
- [ROCR100](#rocr100)
|
||||
- [RSI](#rsi)
|
||||
- [SAR](#sar)
|
||||
- [SAREXT](#sarext)
|
||||
- [SMA](#sma)
|
||||
- [STDDEV](#stddev)
|
||||
- [STOCH](#stoch)
|
||||
- [STOCHF](#stochf)
|
||||
- [STOCHRSI](#stochrsi)
|
||||
- [T3](#t3)
|
||||
- [TEMA](#tema)
|
||||
- [TRANGE](#trange)
|
||||
- [TRIMA](#trima)
|
||||
- [TRIX](#trix)
|
||||
- [TSF](#tsf)
|
||||
- [TYPPRICE](#typprice)
|
||||
- [ULTOSC](#ultosc)
|
||||
- [VARIANCE](#variance)
|
||||
- [WCLPRICE](#wclprice)
|
||||
- [WILLR](#willr)
|
||||
- [WMA](#wma)
|
||||
|
||||
## API
|
||||
|
||||
### accbands
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### ad
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### adosc
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
|
||||
### adx
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### adxr
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### apo
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
- optInMAType
|
||||
|
||||
### aroon
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### aroonosc
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### atr
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### avgprice
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### bbands
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
- optInNbDevUp
|
||||
- optInNbDevDn
|
||||
- optInMAType
|
||||
|
||||
### bop
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### cci
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### cmo
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### dema
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### dx
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### ema
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### ht_dcperiod
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### ht_dcphase
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### ht_phasor
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### ht_sine
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### ht_trendline
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### ht_trendmode
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### imi
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### kama
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### linearreg
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### linearreg_angle
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### linearreg_intercept
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### linearreg_slope
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### ma
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
- optInMAType
|
||||
|
||||
### macd
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
- optInSignalPeriod
|
||||
|
||||
### macdext
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInFastMAType
|
||||
- optInSlowPeriod
|
||||
- optInSlowMAType
|
||||
- optInSignalPeriod
|
||||
- optInSignalMAType
|
||||
|
||||
### macdfix
|
||||
|
||||
Required parameters:
|
||||
|
||||
- SignalPeriod
|
||||
|
||||
### mama
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastLimit
|
||||
- optInSlowLimit
|
||||
|
||||
### mavp
|
||||
|
||||
Required parameters:
|
||||
|
||||
- inPeriods
|
||||
- optInMinPeriod
|
||||
- optInMaxPeriod
|
||||
- optInMAType
|
||||
|
||||
### max
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### maxindex
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### medprice
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### mfi
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### midpoint
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### midprice
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### min
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### minindex
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### minmax
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### minmaxindex
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### minus_di
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### minus_dm
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### mom
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### natr
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### obv
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### plus_di
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### plus_dm
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### ppo
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
- optInMAType
|
||||
|
||||
### roc
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### rocp
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### rocr
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### rocr100
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### rsi
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### sar
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInAcceleration
|
||||
- optInMaximum
|
||||
|
||||
### sarext
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInStartValue
|
||||
- optInOffsetOnReverse
|
||||
- optInAccelerationInitLong
|
||||
- optInAccelerationLong
|
||||
- optInAccelerationMaxLong
|
||||
- optInAccelerationInitShort
|
||||
- optInAccelerationShort
|
||||
- optInAccelerationMaxShort
|
||||
|
||||
### sma
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### stddev
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
- optInNbDev
|
||||
|
||||
### stoch
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastK_Period
|
||||
- optInSlowK_Period
|
||||
- optInSlowK_MAType
|
||||
- optInSlowD_Period
|
||||
- optInSlowD_MAType
|
||||
|
||||
### stochf
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastK_Period
|
||||
- optInFastD_Period
|
||||
- optInFastD_MAType
|
||||
|
||||
### stochrsi
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
- optInFastK_Period
|
||||
- optInFastD_Period
|
||||
- optInFastD_MAType
|
||||
|
||||
### t3
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
- optInFastK_Period
|
||||
- optInFastD_Period
|
||||
- optInFastD_MAType
|
||||
|
||||
### tema
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### trange
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### trima
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### trix
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### tsf
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### typprice
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### ultosc
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### variance
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
- optInNbDev
|
||||
|
||||
### wclprice
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### willr
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### wma
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
@@ -0,0 +1,709 @@
|
||||
# Tulip indicators
|
||||
|
||||
When writing [your own strategy](./creating_a_trading_method.md) you can use all indicators offered by [the Tulip Indicators library](https://tulipindicators.org/). 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.
|
||||
|
||||
- [AD](#ad)
|
||||
- [ADOSC](#adosc)
|
||||
- [ADX](#adx)
|
||||
- [ADXR](#adxr)
|
||||
- [AO](#ao)
|
||||
- [APO](#apo)
|
||||
- [AROON](#aroon)
|
||||
- [AROONOSC](#aroonosc)
|
||||
- [ATR](#atr)
|
||||
- [AVGPRICE](#avgprice)
|
||||
- [BBANDS](#bbands)
|
||||
- [BOP](#bop)
|
||||
- [CCI](#cci)
|
||||
- [CMO](#cmo)
|
||||
- [CVI](#cvi)
|
||||
- [DEMA](#dema)
|
||||
- [DI](#di)
|
||||
- [DM](#dm)
|
||||
- [DPO](#dpo)
|
||||
- [DX](#dx)
|
||||
- [EMA](#ema)
|
||||
- [EMV](#emv)
|
||||
- [FISHER](#fisher)
|
||||
- [FOSC](#fosc)
|
||||
- [HMA](#hma)
|
||||
- [KAMA](#kama)
|
||||
- [KVO](#kvo)
|
||||
- [LINREG](#linreg)
|
||||
- [LINREGINTERCEPT](#linregintercept)
|
||||
- [LINREGSLOPE](#linregslope)
|
||||
- [MARKETFI](#marketfi)
|
||||
- [MASS](#mass)
|
||||
- [MEDPRICE](#medprice)
|
||||
- [MFI](#mfi)
|
||||
- [MSW](#msw)
|
||||
- [NATR](#natr)
|
||||
- [NVI](#nvi)
|
||||
- [OBV](#obv)
|
||||
- [PPO](#ppo)
|
||||
- [PSAR](#psar)
|
||||
- [PVI](#pvi)
|
||||
- [QSTICK](#qstick)
|
||||
- [ROC](#roc)
|
||||
- [ROCR](#rocr)
|
||||
- [RSI](#rsi)
|
||||
- [SMA](#sma)
|
||||
- [STOCH](#stoch)
|
||||
- [SUM](#sum)
|
||||
- [TEMA](#tema)
|
||||
- [TR](#tr)
|
||||
- [TRIMA](#trima)
|
||||
- [TRIX](#trix)
|
||||
- [TSF](#tsf)
|
||||
- [TYPPRICE](#typprice)
|
||||
- [ULTOSC](#ultosc)
|
||||
- [VHF](#vhf)
|
||||
- [VIDYA](#vidya)
|
||||
- [VOLATILITY](#volatility)
|
||||
- [VOSC](#vosc)
|
||||
- [VWMA](#vwma)
|
||||
- [WAD](#wad)
|
||||
- [WCPRICE](#wcprice)
|
||||
- [WILDERS](#wilders)
|
||||
- [WILLR](#willr)
|
||||
- [WMA](#wma)
|
||||
- [ZLEMA](#zlema)
|
||||
|
||||
## API
|
||||
|
||||
### ad
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### adosc
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
|
||||
### adx
|
||||
|
||||
More information on the [**Average Directonal Movement Index**](https://en.wikipedia.org/wiki/Average_directional_movement_index)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### adxr
|
||||
|
||||
The **Average Directional Movement Index Rating** is used as a risk indicator for a security in an [adx](#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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### ao
|
||||
|
||||
More information about the [**Awesome Oscillator**](https://www.tradingview.com/wiki/Awesome_Oscillator_(AO))
|
||||
|
||||
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:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
|
||||
### aroon
|
||||
|
||||
More information about the [Aroon](https://www.tradingview.com/wiki/Aroon) Indicator.
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### atr
|
||||
|
||||
More information about the [Average True Range](https://www.tradingview.com/wiki/Average_True_Range_(ATR))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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](https://www.tradingview.com/wiki/Bollinger_Bands_(BB))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
- optInNbStdDevs
|
||||
|
||||
### 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](https://www.tradingview.com/wiki/Commodity_Channel_Index_(CCI))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### cvi
|
||||
|
||||
More information about the [Chaikin Volatility Index](https://www.tradingview.com/wiki/Chaikin_Oscillator) also called the Chaikin Oscillator.
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### dema
|
||||
|
||||
More information about the [DEMA](https://en.wikipedia.org/wiki/Double_exponential_moving_average)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### di
|
||||
|
||||
More information about the [Directional Indicator](https://en.wikipedia.org/wiki/Average_directional_movement_index)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### dm
|
||||
|
||||
More information about the [Directional Movement Index](https://en.wikipedia.org/wiki/Average_directional_movement_index)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### dpo
|
||||
|
||||
More information about the [Detrended Price Oscillator](https://en.wikipedia.org/wiki/Detrended_price_oscillator)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### dx
|
||||
|
||||
More information about the [Directional Movement Index](https://en.wikipedia.org/wiki/Average_directional_movement_index)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- C = Current Price
|
||||
- P = Previous periods EMA (A SMA is used for the first periods calculations)
|
||||
- K = Exponential smoothing constant
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### emv
|
||||
|
||||
More information about the [Ease of Movement](https://www.tradingview.com/wiki/Ease_of_Movement_(EOM))
|
||||
|
||||
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:
|
||||
|
||||
- "ln" denotes the abbreviated form of the natural logarithm
|
||||
- "X" denotes the transformation of price to a level between -1 and 1 for ease of calculation
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- KAMA(t) is the new adaptive moving average value
|
||||
- KAMA(t-1) is the previous adaptive moving average value
|
||||
- Price is the current price
|
||||
- sc(t) is the smoothing constant
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### linregintercept
|
||||
|
||||
More information about the [Linear Regression Intercept](https://en.wikipedia.org/wiki/Simple_linear_regression)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### linregslope
|
||||
|
||||
More information about the [Linear Regression Intercept](https://en.wikipedia.org/wiki/Simple_linear_regression)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### macd
|
||||
|
||||
More information about the [MACD](https://www.tradingview.com/wiki/MACD_(Moving_Average_Convergence/Divergence))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
- optInSignalPeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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](https://www.tradingview.com/wiki/Money_Flow_(MFI))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optIn
|
||||
|
||||
### natr
|
||||
|
||||
The Normalized Average True Range is a measure of volatility.
|
||||
It is calculated as follows:
|
||||
|
||||
natr = (atr(t) / close(t)) * 100
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### nvi
|
||||
|
||||
More information about the [NVI](https://en.wikipedia.org/wiki/Negative_volume_index)
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### obv
|
||||
|
||||
More information about the [OBV](https://www.tradingview.com/wiki/On_Balance_Volume_(OBV))
|
||||
|
||||
This indicator does not require any parameters.
|
||||
|
||||
### ppo
|
||||
|
||||
More information about the [PPO](https://www.tradingview.com/wiki/Price_Oscillator_(PPO))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
|
||||
### psar
|
||||
|
||||
More information about the [Parabolic SAR](https://www.tradingview.com/wiki/Parabolic_SAR_(SAR))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInAcceleration
|
||||
- optInMaximum
|
||||
|
||||
### pvi
|
||||
|
||||
More information about the [PVI](https://en.wikipedia.org/wiki/Negative_volume_index)
|
||||
|
||||
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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### roc
|
||||
|
||||
More information about the [Rate of Change](https://www.tradingview.com/wiki/Rate_of_Change_(ROC))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### rocr
|
||||
|
||||
Rate Of Change Ratio calculates the change between the current price and the price n bars ago.
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### rsi
|
||||
|
||||
More information about the [RSI](https://www.tradingview.com/wiki/Relative_Strength_Index_(RSI))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### sma
|
||||
|
||||
More information about the [SMA](https://www.tradingview.com/wiki/Moving_Average)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### stoch
|
||||
|
||||
More information about the [STOCH](https://www.tradingview.com/wiki/Stochastic_(STOCH))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastKPeriod
|
||||
- optInSlowKPeriod
|
||||
- optInSlowDPeriod
|
||||
|
||||
### sum
|
||||
|
||||
The Sum Over Period indicator simply returns the sum of the last n bars.
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- Day's high minus day's low
|
||||
- The absolute value of the day's high minus the previous day's close
|
||||
- The absolute value of the day's low minus the previous day's close
|
||||
|
||||
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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### trix
|
||||
|
||||
More information about the [TRIX](https://www.tradingview.com/wiki/TRIX)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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](https://www.tradingview.com/wiki/Ultimate_Oscillator_(UO))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod1
|
||||
- optInTimePeriod2
|
||||
- optInTimePeriod3
|
||||
|
||||
### 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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### vidya
|
||||
|
||||
The Variable Index Dynamic Average indicator modifies the Exponential Moving Average by varying the smoothness based on recent volatility.
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
- optInAlpha
|
||||
|
||||
### volatility
|
||||
|
||||
The Annualized Historical Volatility indicator calculates the volatility over a moving window.
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- optInFastPeriod
|
||||
- optInSlowPeriod
|
||||
|
||||
### vwma
|
||||
|
||||
The Volume Weighted Moving Average is simalair to a Simple Moving Average, but it weights each bar by its volume.
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### 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:
|
||||
|
||||
- Williams A/D = Today's A/D + Yesterday's Williams A/D
|
||||
|
||||
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](#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:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### willr
|
||||
|
||||
More information about the [Williams R](https://www.tradingview.com/wiki/Williams_%25R_(%25R))
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### wma
|
||||
|
||||
More information about the [WMA](https://en.wikipedia.org/wiki/Moving_average#Simple_moving_average)
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
|
||||
### zlema
|
||||
|
||||
Zero-Lag Exponential Moving Average modifies a Exponential Moving Average to greatly reduce lag.
|
||||
|
||||
Required parameters:
|
||||
|
||||
- optInTimePeriod
|
||||
Reference in new issue
Block a user