03-13-2018, 01:51 AM
(This post was last modified: 03-13-2018, 01:58 AM by riesgo.rafael.)
/*
Ichimoku Indicator ../strategies/indicators/ICHIMOKU.js
*/
var Indicator = function(){
this.input = 'candle';
this.highs = new Array(52);
this.lows = new Array(52);
this.age = 0;
this.tenkan = null;
this.kijun = null;
this.senkouSpanA = null;
this.senkouSpanB = null;
}
Indicator.prototype.update = function(candle) {
this.highs.push(candle.high);
this.lows.push(candle.low);
this.age++
if(this.age >= 52){
// Calc
this.tenkan = ( Math.max(...this.highs.slice(-9)) + Math.min(...this.lows.slice(-9)) ) / 2;
this.kijun = ( Math.max(...this.highs.slice(-26)) + Math.min(...this.lows.slice(-26)) ) / 2;
this.senkouSpanA = (this.tenkan + this.kijun) / 2;
this.senkouSpanB = ( Math.max(...this.highs.slice(-52)) + Math.min(...this.lows.slice(-52)) ) / 2;
}
}
module.exports = Indicator;
------------------------------------------------------------------------------------------------------------------------------------------------------
// . ./strategies/ICHIMOKU.js
var log = require('../core/log.js');
strat.init = function(){
// Add Ichimoku Indicator
this.addIndicator('ichimoku', 'ICHIMOKU');
}
strat.check = function(){
var ichimoku = this.indicators.ichimoku;
//ICHIMOKU INDICATOR
log.debug('ICHIMOKU INDICATOR');
log.debug('tenkan:', ichimoku.tenkan);
log.debug('kijun:', ichimoku.kijun);
log.debug('senkouSpanA:', ichimoku.senkouSpanA);
log.debug('senkouSpanB :', ichimoku.senkouSpanB );
log.debug('------------------------------------------');
}
Ichimoku Indicator ../strategies/indicators/ICHIMOKU.js
*/
var Indicator = function(){
this.input = 'candle';
this.highs = new Array(52);
this.lows = new Array(52);
this.age = 0;
this.tenkan = null;
this.kijun = null;
this.senkouSpanA = null;
this.senkouSpanB = null;
}
Indicator.prototype.update = function(candle) {
this.highs.push(candle.high);
this.lows.push(candle.low);
this.age++
if(this.age >= 52){
// Calc
this.tenkan = ( Math.max(...this.highs.slice(-9)) + Math.min(...this.lows.slice(-9)) ) / 2;
this.kijun = ( Math.max(...this.highs.slice(-26)) + Math.min(...this.lows.slice(-26)) ) / 2;
this.senkouSpanA = (this.tenkan + this.kijun) / 2;
this.senkouSpanB = ( Math.max(...this.highs.slice(-52)) + Math.min(...this.lows.slice(-52)) ) / 2;
}
}
module.exports = Indicator;
------------------------------------------------------------------------------------------------------------------------------------------------------
// . ./strategies/ICHIMOKU.js
var log = require('../core/log.js');
strat.init = function(){
// Add Ichimoku Indicator
this.addIndicator('ichimoku', 'ICHIMOKU');
}
strat.check = function(){
var ichimoku = this.indicators.ichimoku;
//ICHIMOKU INDICATOR
log.debug('ICHIMOKU INDICATOR');
log.debug('tenkan:', ichimoku.tenkan);
log.debug('kijun:', ichimoku.kijun);
log.debug('senkouSpanA:', ichimoku.senkouSpanA);
log.debug('senkouSpanB :', ichimoku.senkouSpanB );
log.debug('------------------------------------------');
}