Changing EMA to DEMA in a native strat (help please)
#1
Hi all,

I want to change the below strat from using EMA to using DEMA but if i change
 'this.addIndicator('short', 'EMA', this.settings.short)' to   this.addIndicator('short', 'DEMA', this.settings.short). 

Then i get the error in fig 2, the only thing that changes is the addition of the letter D. Even if

This is the working code, when i change 'EMA' to 'DEMA' i get the error in fig 2


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

var method = {};

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

 this.addIndicator('short', 'EMA', this.settings.short)
 this.addIndicator('medium', 'EMA', this.settings.medium)
 this.addIndicator('long', 'EMA', 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)

 if((this.indicators.short.result > this.indicators.medium.result) && (this.indicators.medium.result > this.indicators.long.result)) {
 log.info('We are in an UP trend: Price =', this.indicators.short.result.toFixed(8))
} else if(this.indicators.medium.result < this.indicators.long.result) {
   log.info('We are in a DOWN trend: Price =', this.indicators.short.result.toFixed(8))
 }
}

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')
   log.info('Were going long')
 } else if((short < medium) && (medium > long)) {
   this.advice('short')
   log.info('Were getting outta this')
 } else if((short > medium) && (medium < long)) {
   this.advice('short')
   log.info('Were getting outta this')
 } else {
   this.advice();
 }
}

module.exports = method;

fig 2

Code:
/root/gekko/strategies/TMA2.js:7
 this.requiredHistory = this.settings.long;
                                      ^

TypeError: Cannot read property 'long' of undefined
   at Base.method.init (/root/gekko/strategies/TMA2.js:7:40)
   at Base.bound [as init] (/root/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at new Base (/root/gekko/plugins/tradingAdvisor/baseTradingMethod.js:70:8)
   at Actor.setupTradingMethod (/root/gekko/plugins/tradingAdvisor/tradingAdvisor.js:60:17)
   at Actor.bound [as setupTradingMethod] (/root/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at new Actor (/root/gekko/plugins/tradingAdvisor/tradingAdvisor.js:23:8)
   at load (/root/gekko/core/pluginUtil.js:98:22)
   at /root/gekko/node_modules/async/dist/async.js:1156:9
   at replenish (/root/gekko/node_modules/async/dist/async.js:1030:17)
   at iterateeCallback (/root/gekko/node_modules/async/dist/async.js:1015:17)
root@vps520385:~/gekko# node gekko --config test.js --backtest
Help please, i'm guessing EMA and DEMA read code different but the DEMA indicator uses the EMA indicator??/

Thanks

EDIT: @askmike i hope this makes it clearer as to where my issue is.
  Reply


Messages In This Thread
Changing EMA to DEMA in a native strat (help please) - by Kris191 - 07-26-2018, 02:40 PM
RE: Help again!! - by askmike - 07-27-2018, 02:55 AM

Forum Jump:


Users browsing this thread: