02-05-2018, 11:38 AM
(This post was last modified: 02-05-2018, 12:30 PM by tommiehansen.)
Added backtest for NEO-USDT.
Began working with an alternative that uses MA for RSI in order to smooth out the values.
So far it really hasn't worked out that great or given any increased benefits but further testing would be needed.
A generic SMA function was written which might be useful for someone:
Just supply it with name, price (candle.close etc) and points (number of points to use).
Began working with an alternative that uses MA for RSI in order to smooth out the values.
So far it really hasn't worked out that great or given any increased benefits but further testing would be needed.
A generic SMA function was written which might be useful for someone:
Code:
var strat = {
/* your init... */
init: function() {},
/* simple moving average (for any values) : returns current average for 'name' */
sma: function(name, price, points)
{
// create arr if not exist + generate array
if( !this[name] )
{
let a = 0, b = [];
for (a; a < points; a++) { b[a] = 0; }
this[name] = b;
}
let arr = this[name],
len = arr.length;
arr[len] = price; // add new to last in array
arr.shift(); // remove first (old) from array (keeping max order)
this[name] = arr; // set/save
// calculate current average
let i = 0,
total = 0;
for( i; i < len; i++ ) { total += arr[i]; }
let avg = total / len;
return avg;
},
// your check
check: function() {}
// your end
end: function() {}
}
Just supply it with name, price (candle.close etc) and points (number of points to use).