Skip to content

Instantly share code, notes, and snippets.

@askmike
Created December 9, 2018 12:59
Show Gist options
  • Save askmike/f7c3ac70b26cf2fe4e4f93f0e2437877 to your computer and use it in GitHub Desktop.
Save askmike/f7c3ac70b26cf2fe4e4f93f0e2437877 to your computer and use it in GitHub Desktop.
example on using a gekko indicator with non standard input
// Within Gekko the easiest way to use indicators is to use the addIndicator interface:
this.addIndicator('myEma', 'EMA', 10);
// However this way you have little control over what data goes into the indicator (always market data)
// If you want to put output of another indicator into your EMA you cannot use this interface and have to
// manually import the indicator that you want to feed other data, for example:
const EMA = require('./indicators/EMA');
const strat = {};
strat.init = () => {
// use normal RSI
this.addIndicator('myRSI', 'RSI', 10);
// create your custom EMA
this.customEMA = new EMA(10);
}
strat.update = () => {
// manually put RSI data calculated by Gekko into your own EMA
this.customEMA.update(this.indicators.myRSI.result);
}
strat.check = () => {
// check your custom EMA result
const EMA_of_RSI = this.customEMA.result;
if(EMA_of_RSI < 1) {
// your stuff
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment