first commit
This commit is contained in:
commit
aa7869eb33
386 files changed
+69375
No files matched your search
@@ -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;
|
||||
Reference in new issue
Block a user