first commit

This commit is contained in:
Francois Klieber committed 2021-06-06 20:25:14 +02:00
commit aa7869eb33
386 files changed
+69375

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
// required indicators
var EMA = require('./EMA.js');
var Indicator = function(config) {
this.input = 'price';
this.diff = false;
this.short = new EMA(config.short);
this.long = new EMA(config.long);
this.signal = new EMA(config.signal);
}
Indicator.prototype.update = function(price) {
this.short.update(price);
this.long.update(price);
this.calculateEMAdiff();
this.signal.update(this.diff);
this.result = this.diff - this.signal.result;
}
Indicator.prototype.calculateEMAdiff = function() {
var shortEMA = this.short.result;
var longEMA = this.long.result;
this.diff = shortEMA - longEMA;
}
module.exports = Indicator;