Ichimoku Indicator
#11
Put  

Code:
var strat = {};

above

Code:
strat.init = function(){...
  Reply
#12
(05-29-2018, 02:42 AM)PatTrends Wrote: Put  

Code:
var strat = {};

above

Code:
strat.init = function(){...

Thank you but again I'm facing another error:

Code:
 <-- POST /api/backtest
2018-05-29 23:16:10 (INFO):    Setting up Gekko in backtest mode
2018-05-29 23:16:10 (INFO):    
2018-05-29 23:16:10 (INFO):    Setting up:
2018-05-29 23:16:10 (INFO):         Trading Advisor
2018-05-29 23:16:10 (INFO):         Calculate trading advice
2018-05-29 23:16:10 (INFO):         Using the strategy: ICHIMOKU
 xxx POST /api/backtest 500 2,041ms -

 Error: non-error thrown: Child process has died.
     at Object.onerror (/home/full/gekko/node_modules/koa/lib/context.js:105:40)
     at process._tickCallback (internal/process/next_tick.js:109:7)

This seems more tricky, cause it is not well explained.
Could you please help me another time?

Thank you!

my code:
Code:
var log = require('../core/log.js');

var strat = {};

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;
  Reply
#13
Did you write this indicator?

I would install the npm version Fizcko mentioned. Then just add the following line to the beginning of your strat near the "var log" line.


Code:
var Ichimoku = require("ichimoku");


then add this to your strat.init().


Code:
this.ichimoku = new Ichimoku({
   conversionPeriod : this.settings.conversionPeriod,
   basePeriod       : this.settings.basePeriod,
   spanPeriod       : this.settings.spanPeriod,
   displacement     : this.settings.displacement,
   values           : []
 });


where 'this.settings.XXX' refers to XXX setting in your toml file.

I have my version set up slightly different now, but that should get you going.
  Reply


Forum Jump:


Users browsing this thread: