Potentially Useful Strategy (Inverse Fisher Transform RSI)
#5
Hi 
Probably late but i managed to modify mark.sch`s indicator and get it to work like this.He did the hard work.I just modified it :Smile
Thx to him
Here is the indicator:
copy this into /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;


 Then copy this to /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;
Then you create it in your strat with:

var iftrsiParameters = {rsiInterval: 14, wmaLength: 8};
this.addIndicator('iftrsi', 'IFTRSI', iftrsiParameters);

And update it in:

strat.update = function(candle) {
this.indicators.iftrsi.update(candle);
}

Later use it with:

this.indicators.iftrsi.result

Hope this helps Smile
GL
  Reply


Messages In This Thread
RE: Potentially Useful Strategy (Inverse Fisher Transform RSI) - by Remo - 11-11-2018, 05:43 PM

Forum Jump:


Users browsing this thread: