Ichimoku Indicator
#7
/*
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('------------------------------------------');

}
  Reply


Messages In This Thread
Ichimoku Indicator - by PatTrends - 02-28-2018, 10:18 PM
RE: Ichimoku Indicator - by PatTrends - 03-01-2018, 02:12 PM
RE: Ichimoku Indicator - by Fizcko - 03-01-2018, 05:01 PM
RE: Ichimoku Indicator - by muditgrover - 03-09-2018, 09:20 AM
RE: Ichimoku Indicator - by edoe - 03-10-2018, 06:09 AM
RE: Ichimoku Indicator - by PatTrends - 03-03-2018, 08:00 PM
RE: Ichimoku Indicator - by riesgo.rafael - 03-13-2018, 01:51 AM
RE: Ichimoku Indicator - by Kris191 - 03-14-2018, 05:15 AM
RE: Ichimoku Indicator - by PatTrends - 03-20-2018, 09:36 PM
RE: Ichimoku Indicator - by palofug87 - 05-27-2018, 04:19 PM
RE: Ichimoku Indicator - by PatTrends - 05-29-2018, 02:42 AM
RE: Ichimoku Indicator - by palofug87 - 05-29-2018, 09:19 PM
RE: Ichimoku Indicator - by PatTrends - 05-31-2018, 06:44 PM
RE: Ichimoku Indicator - by ardialamwijaya - 11-07-2019, 04:16 AM

Forum Jump:


Users browsing this thread: