This repository has been archived on 2025-10-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
gekko/strategies/TMA.js
T
2021-06-06 20:25:14 +02:00

35 lines
928 B
JavaScript

var method = {};
method.init = function() {
this.name = 'Triple Moving Average';
this.requiredHistory = this.settings.long;
this.addIndicator('short', 'SMA', this.settings.short)
this.addIndicator('medium', 'SMA', this.settings.medium)
this.addIndicator('long', 'SMA', this.settings.long)
}
method.update = function(candle) {
this.indicators.short.update(candle.close)
this.indicators.medium.update(candle.close)
this.indicators.long.update(candle.close)
}
method.check = function() {
const short = this.indicators.short.result;
const medium = this.indicators.medium.result;
const long = this.indicators.long.result;
if((short > medium) && (medium > long)) {
this.advice('long')
} else if((short < medium) && (medium > long)) {
this.advice('short')
} else if(((short > medium) && (medium < long))) {
this.advice('short')
} else {
this.advice();
}
}
module.exports = method;