A little code help please.
#1
Hello,

I'm looking for some advice on how to get this strat to log in CLI the current indicator values & current price on every candle tick. I have included the strat code below, if someone could help me i would appreciate it massively...

Code:
var method = {};

method.init = function() {
 this.name = 'Triple Moving Average';
 this.requiredHistory = this.settings.long;

 this.addIndicator('short', 'SMA', this.settings.short)
 this.addIndicator('medium', 'SMA', this.settings.medium)
 this.addIndicator('long', 'SMA', this.settings.long)
}

method.update = function(candle) {
 this.indicators.short.update(candle.close)
 this.indicators.medium.update(candle.close)
 this.indicators.long.update(candle.close)
}

method.check = function() {
 const short = this.indicators.short.result;
 const medium = this.indicators.medium.result;
 const long = this.indicators.long.result;

 if((short > medium) && (medium > long)) {
   this.advice('long')
 } else if((short < medium) && (medium > long)) {
   this.advice('short')
 } else if(((short > medium) && (medium < long))) {
   this.advice('short')
 } else {
   this.advice();
 }
}

module.exports = method;


Thank you
  Reply


Forum Jump:


Users browsing this thread: