[Beginner] Undefined
#1
I am trying to get comfortable with gekko and Javascript to script my own strategy. I thought to begin my quest by getting an example strategy working in backtesting.
Unfortunately I couldn't get the native strategy as for the Tulip strategy to work.

When I use this for the native strategy:
Code:
var strat = {};

strat.init = function() {

  var parameters = {short: 10, long: 20, signal: 9};
this.addIndicator('mynativemacd', 'MACD', parameters);
}

strat.check = function(candle) {
 
 var result = this.indicators.mynativemacd.result;

 console.log(this.indicator); 
}    

module.exports = strat;

I got this:

Code:
   ______   ________  __    __  __    __   ______
  /      \ /        |/  |  /  |/  |  /  | /      \
 /$$$$$$  |$$$$$$$$/ $$ | /$$/ $$ | /$$/ /$$$$$$  |
 $$ | _$$/ $$ |__    $$ |/$$/  $$ |/$$/  $$ |  $$ |
 $$ |/    |$$    |   $$  $$<   $$  $$<   $$ |  $$ |
 $$ |$$$$ |$$$$$/    $$$$$  \  $$$$$  \  $$ |  $$ |
 $$ \__$$ |$$ |_____ $$ |$$  \ $$ |$$  \ $$ \__$$ |
 $$    $$/ $$       |$$ | $$  |$$ | $$  |$$    $$/
  $$$$$$/  $$$$$$$$/ $$/   $$/ $$/   $$/  $$$$$$/

       Gekko v0.6.6
       I'm gonna make you rich, Bud Fox.


2018-10-20 18:17:38 (INFO):     Setting up Gekko in backtest mode
2018-10-20 18:17:38 (INFO):
2018-10-20 18:17:38 (WARN):     The plugin Candle writer does not support the mode backtest. It has been disabled.
2018-10-20 18:17:38 (INFO):     Setting up:
2018-10-20 18:17:38 (INFO):              Trading Advisor
2018-10-20 18:17:38 (INFO):              Calculate trading advice
2018-10-20 18:17:38 (INFO):              Using the strategy: dump
2018-10-20 18:17:38 (INFO):

2018-10-20 18:17:38 (INFO):     Setting up:
2018-10-20 18:17:38 (INFO):              Paper Trader
2018-10-20 18:17:38 (INFO):              Paper trader that simulates fake trades.
2018-10-20 18:17:38 (INFO):

2018-10-20 18:17:38 (INFO):     Setting up:
2018-10-20 18:17:38 (INFO):              Performance Analyzer
2018-10-20 18:17:38 (INFO):              Analyzes performances of trades
2018-10-20 18:17:38 (INFO):

2018-10-20 18:17:38 (INFO):     Scanning local history for backtestable dateranges.
2018-10-20 18:17:38 (DEBUG):    Available 43199
2018-10-20 18:17:38 (DEBUG):    Optimal 43198
2018-10-20 18:17:38 (INFO):     Gekko is able to fully use the local history.
2018-10-20 18:17:38 (INFO):     Gekko was able to find a single daterange in the locally stored history:
2018-10-20 18:17:38 (INFO):              from: 2018-09-20 13:39:00
2018-10-20 18:17:38 (INFO):              to: 2018-10-20 13:37:00

2018-10-20 18:17:38 (INFO):             WARNING: BACKTESTING FEATURE NEEDS PROPER TESTING
2018-10-20 18:17:38 (INFO):             WARNING: ACT ON THESE NUMBERS AT YOUR OWN RISK!

undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined


When I use this for the Tulip strategy:
Code:
var strat = {};

strat.init = function() {

    this.addTulipIndicator('ema10', 'ema', {
        optInTimePeriod: 10
    });
    this.addTulipIndicator('ema21', 'ema', {
        optInTimePeriod: 21
    });
}
strat.check = function(candle) {

    const ema10 = this.tulipIndicator.ema10.result.result;
    const ema21 = this.tulipIndicator.ema21.result.result;

    console.log({ema10, ema21});

}

module.exports = strat;

I got this:
Code:
   ______   ________  __    __  __    __   ______
  /      \ /        |/  |  /  |/  |  /  | /      \
 /$$$$$$  |$$$$$$$$/ $$ | /$$/ $$ | /$$/ /$$$$$$  |
 $$ | _$$/ $$ |__    $$ |/$$/  $$ |/$$/  $$ |  $$ |
 $$ |/    |$$    |   $$  $$<   $$  $$<   $$ |  $$ |
 $$ |$$$$ |$$$$$/    $$$$$  \  $$$$$  \  $$ |  $$ |
 $$ \__$$ |$$ |_____ $$ |$$  \ $$ |$$  \ $$ \__$$ |
 $$    $$/ $$       |$$ | $$  |$$ | $$  |$$    $$/
  $$$$$$/  $$$$$$$$/ $$/   $$/ $$/   $$/  $$$$$$/

       Gekko v0.6.6
       I'm gonna make you rich, Bud Fox.


2018-10-20 18:39:23 (INFO):     Setting up Gekko in backtest mode
2018-10-20 18:39:23 (INFO):
2018-10-20 18:39:23 (WARN):     The plugin Candle writer does not support the mode backtest. It has been disabled.
2018-10-20 18:39:23 (INFO):     Setting up:
2018-10-20 18:39:23 (INFO):              Trading Advisor
2018-10-20 18:39:23 (INFO):              Calculate trading advice
2018-10-20 18:39:23 (INFO):              Using the strategy: dump
2018-10-20 18:39:23 (INFO):

2018-10-20 18:39:23 (INFO):     Setting up:
2018-10-20 18:39:23 (INFO):              Paper Trader
2018-10-20 18:39:23 (INFO):              Paper trader that simulates fake trades.
2018-10-20 18:39:23 (INFO):

2018-10-20 18:39:23 (INFO):     Setting up:
2018-10-20 18:39:23 (INFO):              Performance Analyzer
2018-10-20 18:39:23 (INFO):              Analyzes performances of trades
2018-10-20 18:39:23 (INFO):

2018-10-20 18:39:23 (INFO):     Scanning local history for backtestable dateranges.
2018-10-20 18:39:23 (DEBUG):    Available 43199
2018-10-20 18:39:23 (DEBUG):    Optimal 43198
2018-10-20 18:39:23 (INFO):     Gekko is able to fully use the local history.
2018-10-20 18:39:23 (INFO):     Gekko was able to find a single daterange in the locally stored history:
2018-10-20 18:39:23 (INFO):              from: 2018-09-20 13:39:00
2018-10-20 18:39:23 (INFO):              to: 2018-10-20 13:37:00

2018-10-20 18:39:23 (INFO):             WARNING: BACKTESTING FEATURE NEEDS PROPER TESTING
2018-10-20 18:39:23 (INFO):             WARNING: ACT ON THESE NUMBERS AT YOUR OWN RISK!

/home/rabberzzz/gekko/node_modules/sqlite3/lib/trace.js:27
                   throw err;
                   ^

TypeError: Cannot read property 'ema10' of undefined
   at Base.strat.check (/home/rabberzzz/gekko/strategies/dump.js:32:36)
   at Base.bound [as check] (/home/rabberzzz/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at Base.propogateTick (/home/rabberzzz/gekko/plugins/tradingAdvisor/baseTradingMethod.js:167:10)
   at Base.bound [as propogateTick] (/home/rabberzzz/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at Base.calculateSyncIndicators (/home/rabberzzz/gekko/plugins/tradingAdvisor/baseTradingMethod.js:129:8)
   at Base.bound [as calculateSyncIndicators] (/home/rabberzzz/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at afterAsync (/home/rabberzzz/gekko/plugins/tradingAdvisor/baseTradingMethod.js:94:10)
   at asyncIndicatorRunner.processCandle (/home/rabberzzz/gekko/plugins/tradingAdvisor/baseTradingMethod.js:105:7)
   at /home/rabberzzz/gekko/plugins/tradingAdvisor/asyncIndicatorRunner.js:103:5
   at /home/rabberzzz/gekko/node_modules/lodash/dist/lodash.js:5144:23
--> in Database#all('\n    SELECT * from candles_EUR_ETH\n    WHERE start <= 1538314739 AND start >= 1538311740\n    ORDER BY start ASC\n  ', [Function])
   at Reader.get (/home/rabberzzz/gekko/plugins/sqlite/reader.js:98:11)
   at Reader.bound [as get] (/home/rabberzzz/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at Market.get (/home/rabberzzz/gekko/core/markets/backtest.js:61:15)
   at Market.bound [as get] (/home/rabberzzz/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at Market.processCandles (/home/rabberzzz/gekko/core/markets/backtest.js:105:10)
   at bound (/home/rabberzzz/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at Statement.<anonymous> (/home/rabberzzz/gekko/plugins/sqlite/reader.js:108:5)

I have searched every post I could find on undefined outcome or undefined property, but still I couldn't find the solution.

Does someone got an idea?
  Reply


Messages In This Thread
[Beginner] Undefined - by Rabberzzz - 10-20-2018, 05:00 PM
RE: [Beginner] Undefined - by askmike - 10-21-2018, 04:23 AM

Forum Jump:


Users browsing this thread: