Gekko Forum
Inverse Fisher RSI Strat- only returns false. - Printable Version

+- Gekko Forum (https://forum.gekko.wizb.it)
+-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html)
+--- Forum: Strategy Development (https://forum.gekko.wizb.it/forum-12.html)
+--- Thread: Inverse Fisher RSI Strat- only returns false. (/thread-58005.html)



Inverse Fisher RSI Strat- only returns false. - lucascostner - 09-11-2019

Hey everyone- hope you can help me out with this. I've been revisiting an old strategy post from a year or so ago. So this doesn't generate any errors when I run it, but something is off because the IFRSI indicator never returns anything. When I console.log to print the result as it runs it always comes back with "false"- it should be returning 0.5 or -0.5. Anyone have any advice for me on this? The two required indicators and the strategy file are below.....


Here is the first indicator:



/indicators/IFTRSI.js   


Code:
var RSI = require('./RSI.js');
var WMA = require('./WMA.js');

var Indicator = function(config) {
 this.result = false;
 this.rsiInterval = config.interval;
 this.wmaLength = config.length;
 this.rsi = new RSI({interval: this.rsiInterval});
this.wma = new WMA({length: this.wmaLength});
}

Indicator.prototype.update = function (candle) {
 this.rsi.update(candle);
 if (this.rsi.result) {
   let v1 = 0.1 * (this.rsi.result - 50);
   this.wma.update(v1);

   if (this.wma.result) { 
       this.result = (Math.exp(2 * this.wma.result)-1) / (Math.exp(2 * this.wma.result)+1);
   }
 }
}

module.exports = Indicator;


Here is the second indicator-


 /indicators/WMA.js


Code:
var Indicator = function(settings) {
   this.input = 'price';
   this.windowLength = settings.length;
   this.prices = [];
   this.result = 0;
   this.age = 0;
   this.sum = 0;
}

Indicator.prototype.update = function(price) {
   var tail = this.prices[this.age] || 0;
   this.prices.push(price);


   var psum =0;
   var pdiv = 0;

   for (var j=0;j<this.prices.length;j++)
   {

       psum += j * this.prices[j];
       pdiv += j;

   }

   this.result = psum/pdiv;
   if (this.prices.length > this.windowLength)
   {
       this.prices.shift()

   }

   this.age = (this.age + 1) % this.windowLength
}

module.exports = Indicator;

And here is the strategy file--


/strategies/IFRSI.js

Code:
var method = {};
var traded = false;
var IFTRSI = require('./indicators/IFTRSI.js');
method.init = function() {
    var iftrsiParameters = {rsiInterval: 14, wmaLength: 8};
    this.addIndicator('iftrsi', 'IFTRSI', iftrsiParameters);
    
}
method.update = function(candle) {
    this.indicators.iftrsi.update(candle);
  
}
method.check = function(candle) {
    var iftResult = this.indicators.iftrsi.result;

    console.log(iftResult);

if ( traded == false && iftResult == -0.5 ){
    this.advice('long')
    traded = true;
    console.log(iftResult);
} else if(traded == true && iftResult == 0.5 ){
    this.advice('short')
    console.log(iftResult);
    traded = false;
}
}


module.exports = method;



RE: Inverse Fisher RSI Strat- only returns false. - vladek666 - 10-05-2019

Fisher je vrlo dobar pokazatelj. Jeste li spremni završiti?

izbriši u
/indicators/IFTRSI.js

console.log (iftResult);

Javite mi kad završim scenarij


RE: Inverse Fisher RSI Strat- only returns false. - lucascostner - 10-06-2019

Yeah I tried using console.log but every time it logs the result it always just comes back “false”. Not sure where the problem is.