Gekko Forum
[TUT] STRATEGIE #5 dynamique stoploss [SHARE] - Printable Version

+- Gekko Forum (https://forum.gekko.wizb.it)
+-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html)
+--- Forum: Guides (https://forum.gekko.wizb.it/forum-22.html)
+--- Thread: [TUT] STRATEGIE #5 dynamique stoploss [SHARE] (/thread-57089.html)



[TUT] STRATEGIE #5 dynamique stoploss [SHARE] - susitronix - 05-03-2018

In this Tutorial we will add a dynamic stoploss.

Stoploss seems to be pretty hard to get right,
because the most approaches would decrease the profit, rather than do good to it.

First one would think, a price.long-absolut-stoploss would work well, but the reallity shows different:
>>>a smaller stop value does increase the errors and loose more than the stop would benefit..!

it simply hurts the strategy as TommieHansen stated.

On the otherside if we set the threshold more loose, then it again does not work too much.


The indicators based stoploss are also interesting but theese have problems with the indication speed,
because:
>>>>>the newest candle.data must first fight against the old averages, before it could seriously indicate a fast change.
>>>thats not always true since they would use multiplication to indicate a fast change.
>>>>>>>THUS also create a lot of false triggers due to multiplication (RSI-based)

so what we do!

i found a easy way is to create our own stop indicator.
Its very simple design:

Code:
this.price.exp = this.price.trades * this.price.dif;
the candle.trades value is intresting.
It seem to indicate the changes pretty faster than enybody else.
But it is a positive number (offcourse!).
For our indicator we wanna have a bipolar output signal, otherwise it would trigger in both trends.
therefore we multiply with the procentage difference between the candles.

The price.dif is a simple procent calculation for the absolut price:
Code:
this.price.dif = ((this.price.last - this.price.close) / this.price.last) * -100;    //LAST LONG
this.price.last = 0;
this.price.last = this.price.close; //BACKUP FOR THE NEXT CANDLE


When goLong we store the candle.close:

Code:
this.price.long = this.price.close;


The stop(trend) logic dos inhibit the RSI trader while in the stop trend.
then a unlock logic will delay the stop trend for not buy to early.

I also adjusted the RSI trader to get better positive results.
4 month
1 month

Binance
BTC/Usdt
candlesize 1min
warmup 10min

For the 4 month period with such a difficult trend, its not bad.
>>>>>>>>its only a rsi and a stoploss...<<<<<<<<<
the one month as expected, is a bit less then the bulltrend

here is the finished code:

Code:
/*
Tutorial:     trendatron #5
           rsi trader
philipp wyler
2018-04-25
*/

var _ = require('lodash');
var log = require('../core/log.js');
var config = require('../core/util.js').getConfig();

var trenda = {};
//<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><
//>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>
//<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><

trenda.init = function () {

   this.name = 'trendatron_2';

   this.allInit();

   this.userMap();

   this.cpuTime();

   this.indInit();

   this.setupLog();
}

trenda.update = function (candle) {

   this.timeCursor();

   this.priceUpdate();

   this.calculus();

   this.resultRSI = this.tulipIndicators.myrsi.result.result;
}

trenda.log = function () {

}
trenda.check = function (candle) {

   this.stop();
   //lets trade...
   if (this.logic.stopabs !== true && this.resultRSI > this.settings.trsRSI.high && this.logic.longpos !== false) {
       this.goShort();
   }
   else if (this.logic.stopabs !== true && this.resultRSI < this.settings.trsRSI.low && this.logic.longpos !== true) {
       this.goLong();
   }
}
//<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><
//>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>
//<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><
trenda.stop = function () {
   if (this.logic.stopabs !== false) {
       if (this.logic.lock !== false && this.resultRSI > this.settings.trsRSI.high) {
           this.logic.lock = false;
       }
       if (this.logic.lock !== true && this.resultRSI < this.settings.trsRSI.low) {
           this.logic.stopabs = false;
           log.debug('-  ' + this.timearr + ' zz---unlock ' + '  stop ' + this.logic.stopabs + '  pc ' + this.price.close.toFixed(2) + '  exp ' + this.price.exp.toFixed(2));
       }
   }
   //SIDECHAIN STOP
   if (this.logic.stopabs !== true && this.logic.longpos !== false && this.stopabsset > this.price.abs) {
       if (this.stopabsexpset > this.price.exp) {
           this.logic.stopabs = true;
           this.logic.lock = true;
           this.goShort();
           this.logic.stopcount++;
           log.debug('-  ' + this.timearr + ' xxxxxxxxxxx ' + '  stop ' + this.logic.stopabs + '  pc ' + this.price.close.toFixed(2) + '  exp ' + this.price.exp.toFixed(2));
       }
   }
   if (this.logic.stopabs !== true && this.logic.longpos !== true && this.stopabsset > this.price.abs) {
       if (this.stopabsexpset > this.price.exp) {
           this.logic.stopabs = true;
           this.logic.lock = true;
           this.logic.waitcount++;
           log.debug('-  ' + this.timearr + ' yyyyyyyyyy ' + '  wait ' + this.logic.stopabs + '  pc ' + this.price.close.toFixed(2) + '  exp ' + this.price.exp.toFixed(2));
       }
   }
}
trenda.goShort = function () {
   this.logic.longpos = false;
   this.advice('short');
   log.debug('>>> ' + this.timearr + ' Short price.close = ' + this.price.close);
}
trenda.goLong = function () {
   this.logic.longpos = true;
   this.advice('long');
   this.price.long = this.price.close;
   log.debug(' <<<' + this.timearr + ' Long price.close = ' + this.price.close);
}
trenda.priceUpdate = function () {
   this.price.close = this.candle.close;
   this.price.low = this.candle.low;
   this.price.high = this.candle.high;
   this.price.volume = this.candle.volume;
   this.price.vwp = this.candle.vwp;
   this.price.trades = this.candle.trades;
}
trenda.calculus = function () {
   this.price.abs = ((this.price.long - this.price.close) / this.price.long) * -100;    //LAST LONG

   this.price.dif = ((this.price.last - this.price.close) / this.price.last) * -100;    //LAST LONG
   this.price.last = 0;
   this.price.last = this.price.close;

   this.price.exp = this.price.trades * this.price.dif;
}

trenda.indInit = function () {
   // define the indicators we need     //move the settings into >>>rsi input length
   this.addTulipIndicator('myrsi', 'rsi', this.customRSIsettings);
}
trenda.allInit = function () {

   //first fetch settings from .toml
   this.customRSIsettings = this.settings.RSI;

   //add candle
   price =
       {
           close: 0,//this.candle
           low: 0,//this.candle
           high: 0,//this.candle
           volume: 0,//this.candle
           vwp: 0,//this.candle
           trades: 0,//this.candle
           long: 0,
           last: 0,
           dif: 0,
           exp: 0
       };
   this.price = price;

   logic =
       {
           longpos: false,
           stopabs: false,
           lock: false,
           globalcount: 0,
           stopcount: 0,
           waitcount: 0
       };
   this.logic = logic;

   this.stopabsset = this.settings.___stop_abs____.stop_abs;
   this.stopabsexpset = this.settings.___stop_abs____.abs_exp;
}
trenda.cpuTime = function () {
   //CPU TIME SET
   this.startTime = new Date();
}
trenda.userMap = function () {

   this.longpos = this.settings.___trendatron___.__longPos;
   month = this.settings._backtest_start_.______month;
   day = this.settings._backtest_start_.__________day;
   hour = this.settings._backtest_start_._____hour;
   minute = this.settings._backtest_start_._minute;

   this.montharr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
   this.month = month;
   this.day = day;
   this.hour = hour;
   this.minute = minute;
   this.timearr = [];
   this.candlesize = this.settings._backtest_start_.candle_size;
}
trenda.timeCursor = function () {
   if (this.logic.globalcount == 0) {
       this.mcount = this.minute;
       this.hcount = this.hour;
       this.dcount = this.day;
       this.moncount = this.month;
   }

   y = this.candlesize;
   for (i = 0; i < y; i++) {
       this.logic.globalcount++;//COUNT BACKTEST CANDLES

       z = this.moncount - 1;
       this.monthframe = this.montharr[z];
       candleminute = this.logic.globalcount % 60;//MINUTE MODULUS////
       this.candleminute = candleminute;
       //HOUR COUNT
       if (this.mcount == 59) {
           this.hcount++;//HOUR COUNT
           this.mcount = 0;
       }
       else if (this.mcount < 59) {
           this.mcount++;
       }
       //DAY COUNT
       if (this.hcount == 24) {
           this.dcount++;//DAY COUNT
           this.hcount = 0;
       }
       //MONTHDAY
       if (this.dcount > (this.monthframe)) {
           this.moncount++;
           this.dcount = 1
       }
       //MONTH
       else if (this.moncount > 12) {
           this.moncount = 1;
       }
       this.candlehour = this.hcount;//HOUR
       this.candleday = this.dcount;//DAY
       this.candlemonth = this.moncount;//MONTH
       this.timearr = [this.candlemonth, this.candleday, this.candlehour, this.candleminute];
   }
}
trenda.setupLog = function () {
   log.info
       (


       '\n' + '\t' + '\t' + '\t' + '\t' +
       '  ...last longpos = ' + this.logic.longpos + '\n' + '\t' + '\t' + '\t' +
       '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' + '\n' + '\t' + '\t' + '\t' +
       '  .....start backtest ' + this.name + ' varactor' + '\n' + '\t' + '\t' + '\t' +
       '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+' + '\n' + '\t' + '\t' + '\t' +
       '\n' + '\t' + '\t' + '\t' +
       '                     <<>>' + '\n' + '\t' + '\t' + '\t' +
       '                 ><<><>><<>>' + '\n' + '\t' + '\t' + '\t' +
       '             >><<>>       <<>><<' + '\n' + '\t' + '\t' + '\t' +
       '        <>><<>    system v3   >><<>>' + '\n' + '\t' + '\t' + '\t' +
       '    <<>><<>  start date ' + this.month + ':' + this.day + ':' + this.hour + ':' + this.minute + ' >><<>>' + '\n' + '\t' + '\t' + '\t' +
       ' ><<>><    ......beginn trading       <>><<>' + '\n' + '\t' + '\t' + '\t' +
       '><<>><            ' + this.name + '         ><>><<' + '\n' + '\t' + '\t' + '\t' +
       '  >><<>>       susitronix d-sign      <<>><<' + '\n' + '\t' + '\t' + '\t' +
       '     >><<<<<>>><<            <<>>><<>><<' + '\n' + '\t' + '\t' + '\t' +
       '              ><<<<>>><<<>>><<>>' + '\n' + '\t' + '\t' + '\t' +
       '                    >>><<<' + '\n' + '\t' + '\t' + '\t' +
       '                      <>' + '\n'
       );
}
trenda.end = function () {
   this.logic.globalcount;
   this.monthdif = (((this.logic.globalcount / 60) / 24) / 30) % 12;
   this.daysdif = ((this.logic.globalcount / 60) / 24) % 30;
   this.hoursdif = (this.logic.globalcount / 60) % 24;
   this.minutesdif = this.logic.globalcount % 60;

   this.globalcountdif = this.logic.globalcount - this.globalcountbegin;

   let seconds = ((new Date() - this.startTime) / 1000),
       minutes = seconds / 60,
       str;
   //CPU TIME CALCULUS IN MILLISECONDS
   this.totaltime = ((minutes / 60) + seconds);
   this.cputime = ((this.totaltime / this.logic.globalcount) * 1000);

   minutes < 1 ? str = seconds.toFixed(2) + ' seconds' : str = minutes.toFixed(2) + ' minutes';

   log.info
       (
       '\n' + '\t' + '\t' +
       '.....backtest started with longpos = ' + this.longpos + '\n' + '\t' +
       '.....stop count = ' + this.logic.stopcount + '\n' + '\t' +
       '.....wait count = ' + this.logic.waitcount + '\n' + '\t' +
       '                                                       ' + '\n' + '\t' +
       '                             <<>>                      ' + '\n' + '\t' +
       '                       <<>><<>><<>><<>>                ' + '\n' + '\t' +
       '                 >><<>><<>><<>><<>><<>><<>><<          ' + '\n' + '\t' +
       '            <<>><<>>     ' + this.name + '     <<>><<>>' + '\n' + '\t' +
       '        <<>><<>>    start date ' + this.month + ':' + this.day + ':' + this.hour + ':' + this.minute + '     <<>><<>>' + '\n' + '\t' +
       '   <<>><<>>         end time ' + this.candlemonth + ':' + this.candleday + ':' + this.candlehour + ':' + this.candleminute + ' finish     <<>><<>>' + '\n' + '\t' +
       ' <<>><<>>      ' + str + ' / candles = ' + this.logic.globalcount + '       <<>><<>>' + '\n' + '\t' +
       '   <<>><<>>    candle cpu time = ' + this.cputime.toFixed(4) + ' mSec       <<>><<>>' + '\n' + '\t' +
       '      >><< <<>><<>><<>>                <<>><<>><<>> <<>> ' + '\n' + '\t' +
       '    <<>><>         <<>><<>><<>><<>><<>><<>>         <<>><< ' + '\n' + '\t' +
       '<<>><<>>><<                <<>><<>>                ><<>><<>>>< ' + '\n' + '\t'
       );
}

module.exports = trenda;

And here the settings .toml

Code:
[___trendatron___]
#<<<>>><<<>>>#
__longPos = false

#>>><<<>>><<#
[_backtest_start_]
__________day = 1
______month = 4
_____hour = 18
_minute = 38
candle_size = 1
#<<<>>><<<>>>#

[RSI]
optInTimePeriod = 30

[trsRSI]
high = 68
low = 30

[___stop_abs____]
stop_abs = -1.7
abs_exp = -250


The actual code for the strat would be fearly small, the rest are just debug tools.
>>>In the following tutorial we will build the hypetrend that can be seen as a complement to the stoploss, function wise.
Also we try to build a macrotrend for the longer trends in the future.

If you have questions to it, feel free to ask here in this topic because i will read them. hope this helps
or if you need some help with your strategie, no worries fire it up


[TUT] STRATEGIE #5 strategie CLI-config settings !!! - susitronix - 06-20-2018

if someone using the gekko CLI-version (terminal) then here is the strategie settings:

Code:
//here you can choose a name for this strategie: (>>>trendatron_tut5)
config.trendatron_tut5 = {

  "___stop_abs____" : {
     "abs_exp" : -250,
     "stop_abs" : -1.7
  },
  "_backtest_start_" : {
     "_minute" : 38,
     "__________day" : 1,
     "candle_size" : 1,
     "______month" : 4,
     "_____hour" : 18
  },
  "RSI" : {
     "optInTimePeriod" : 30
  },
  "trsRSI" : {
     "high" : 68,
     "low" : 30
  },
  "___trendatron___" : {
     "__longPos" : "false"
  }
}
first copie paste into your code editor (notepad++ or Visual Studio Code)
then its always wise to make:
>>>>>format document...
(right click and select: "format document")
then copie/paste into your sample-config.js >>>>>under "CONFIGURING TRADING ADVICE".

offcourse you may want to make all other settings in this config...

the config then looks like this:
Code:
// Everything is explained here:
// @link https://gekko.wizb.it/docs/commandline/plugins.html

var config = {};

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                          GENERAL SETTINGS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.debug = true; // for additional logging / debugging

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                         WATCHING A MARKET
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.watch = {

 // see https://gekko.wizb.it/docs/introduction/supported_exchanges.html
 exchange: 'poloniex',
 currency: 'USDT',
 asset: 'BTC',

 // You can set your own tickrate (refresh rate).
 // If you don't set it, the defaults are 2 sec for
 // okcoin and 20 sec for all other exchanges.
 // tickrate: 20
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                       CONFIGURING TRADING ADVICE
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.tradingAdvisor = {
 enabled: true,
 method: 'MACD',
 candleSize: 60,
 historySize: 10,
}

//TRENDATRON TUTORIAL EXAMPLE STRATEGIE CONFIG
config.trendatron_tut5 = {

  "___stop_abs____" : {
     "abs_exp" : -250,
     "stop_abs" : -1.7
  },
  "_backtest_start_" : {
     "_minute" : 38,
     "__________day" : 1,
     "candle_size" : 1,
     "______month" : 4,
     "_____hour" : 18
  },
  "RSI" : {
     "optInTimePeriod" : 30
  },
  "trsRSI" : {
     "high" : 68,
     "low" : 30
  },
  "___trendatron___" : {
     "__longPos" : "false"
  }
}

// Exponential Moving Averages settings:
config.DEMA = {
 // EMA weight (α)
 // the higher the weight, the more smooth (and delayed) the line
 weight: 21,
 // amount of candles to remember and base initial EMAs on
 // the difference between the EMAs (to act as triggers)
 thresholds: {
   down: -0.025,
   up: 0.025
 }
};

// MACD settings:
config.MACD = {
 // EMA weight (α)
 // the higher the weight, the more smooth (and delayed) the line
 short: 10,
 long: 21,
 signal: 9,
 // the difference between the EMAs (to act as triggers)
 thresholds: {
   down: -0.025,
   up: 0.025,
   // How many candle intervals should a trend persist
   // before we consider it real?
   persistence: 1
 }
};

// PPO settings:
config.PPO = {
 // EMA weight (α)
 // the higher the weight, the more smooth (and delayed) the line
 short: 12,
 long: 26,
 signal: 9,
 // the difference between the EMAs (to act as triggers)
 thresholds: {
   down: -0.025,
   up: 0.025,
   // How many candle intervals should a trend persist
   // before we consider it real?
   persistence: 2
 }
};

// Uses one of the momentum indicators but adjusts the thresholds when PPO is bullish or bearish
// Uses settings from the ppo and momentum indicator config block
config.varPPO = {
 momentum: 'TSI', // RSI, TSI or UO
 thresholds: {
   // new threshold is default threshold + PPOhist * PPOweight
   weightLow: 120,
   weightHigh: -120,
   // How many candle intervals should a trend persist
   // before we consider it real?
   persistence: 0
 }
};

// RSI settings:
config.RSI = {
 interval: 14,
 thresholds: {
   low: 30,
   high: 70,
   // How many candle intervals should a trend persist
   // before we consider it real?
   persistence: 1
 }
};

// TSI settings:
config.TSI = {
 short: 13,
 long: 25,
 thresholds: {
   low: -25,
   high: 25,
   // How many candle intervals should a trend persist
   // before we consider it real?
   persistence: 1
 }
};

// Ultimate Oscillator Settings
config.UO = {
 first: {weight: 4, period: 7},
 second: {weight: 2, period: 14},
 third: {weight: 1, period: 28},
 thresholds: {
   low: 30,
   high: 70,
   // How many candle intervals should a trend persist
   // before we consider it real?
   persistence: 1
 }
};

// CCI Settings
config.CCI = {
   constant: 0.015, // constant multiplier. 0.015 gets to around 70% fit
   history: 90, // history size, make same or smaller than history
   thresholds: {
       up: 100, // fixed values for overbuy upward trajectory
       down: -100, // fixed value for downward trajectory
       persistence: 0 // filter spikes by adding extra filters candles
   }
};

// StochRSI settings
config.StochRSI = {
 interval: 3,
 thresholds: {
   low: 20,
   high: 80,
   // How many candle intervals should a trend persist
   // before we consider it real?
   persistence: 3
 }
};


// custom settings:
config.custom = {
 my_custom_setting: 10,
}

config['talib-macd'] = {
 parameters: {
   optInFastPeriod: 10,
   optInSlowPeriod: 21,
   optInSignalPeriod: 9
 },
 thresholds: {
   down: -0.025,
   up: 0.025,
 }
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                       CONFIGURING PLUGINS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// do you want Gekko to simulate the profit of the strategy's own advice?
config.paperTrader = {
 enabled: true,
 // report the profit in the currency or the asset?
 reportInCurrency: true,
 // start balance, on what the current balance is compared with
 simulationBalance: {
   // these are in the unit types configured in the watcher.
   asset: 1,
   currency: 100,
 },
 // how much fee in % does each trade cost?
 feeMaker: 0.15,
 feeTaker: 0.25,
 feeUsing: 'maker',
 // how much slippage/spread should Gekko assume per trade?
 slippage: 0.05,
}

config.performanceAnalyzer = {
 enabled: true,
 riskFreeReturn: 5
}

// Want Gekko to perform real trades on buy or sell advice?
// Enabling this will activate trades for the market being
// watched by `config.watch`.
config.trader = {
 enabled: false,
 key: '',
 secret: '',
 username: '', // your username, only required for specific exchanges.
 passphrase: '', // GDAX, requires a passphrase.
 orderUpdateDelay: 1, // Number of minutes to adjust unfilled order prices
}

config.adviceLogger = {
 enabled: false,
 muteSoft: true // disable advice printout if it's soft
}

config.pushover = {
 enabled: false,
 sendPushoverOnStart: false,
 muteSoft: true, // disable advice printout if it's soft
 tag: '[GEKKO]',
 key: '',
 user: ''
}

// want Gekko to send a mail on buy or sell advice?
config.mailer = {
 enabled: false,       // Send Emails if true, false to turn off
 sendMailOnStart: true,    // Send 'Gekko starting' message if true, not if false

 email: '',    // Your Gmail address
 muteSoft: true, // disable advice printout if it's soft

 // You don't have to set your password here, if you leave it blank we will ask it
 // when Gekko's starts.
 //
 // NOTE: Gekko is an open source project < https://github.com/askmike/gekko >,
 // make sure you looked at the code or trust the maintainer of this bot when you
 // fill in your email and password.
 //
 // WARNING: If you have NOT downloaded Gekko from the github page above we CANNOT
 // guarantuee that your email address & password are safe!

 password: '',       // Your Gmail Password - if not supplied Gekko will prompt on startup.

 tag: '[GEKKO] ',      // Prefix all email subject lines with this

           //       ADVANCED MAIL SETTINGS
           // you can leave those as is if you
           // just want to use Gmail

 server: 'smtp.gmail.com',   // The name of YOUR outbound (SMTP) mail server.
 smtpauth: true,     // Does SMTP server require authentication (true for Gmail)
         // The following 3 values default to the Email (above) if left blank
 user: '',       // Your Email server user name - usually your full Email address 'me@mydomain.com'
 from: '',       // 'me@mydomain.com'
 to: '',       // 'me@somedomain.com, me@someotherdomain.com'
 ssl: true,        // Use SSL (true for Gmail)
 port: '',       // Set if you don't want to use the default port
}

config.pushbullet = {
   // sends pushbullets if true
 enabled: false,
   // Send 'Gekko starting' message if true
 sendMessageOnStart: true,
   // disable advice printout if it's soft
 muteSoft: true,
   // your pushbullet API key
 key: 'xxx',
   // your email, change it unless you are Azor Ahai
 email: 'jon_snow@westeros.org',
   // will make Gekko messages start mit [GEKKO]
 tag: '[GEKKO]'
};

config.kodi = {
 // if you have a username & pass, add it like below
 // http://user:pass@ip-or-hostname:8080/jsonrpc
 host: 'http://ip-or-hostname:8080/jsonrpc',
 enabled: false,
 sendMessageOnStart: true,
}

config.ircbot = {
 enabled: false,
 emitUpdates: false,
 muteSoft: true,
 channel: '#your-channel',
 server: 'irc.freenode.net',
 botName: 'gekkobot'
}

config.telegrambot = {
 enabled: false,
 token: 'YOUR_TELEGRAM_BOT_TOKEN',
};

config.twitter = {
   // sends pushbullets if true
 enabled: false,
   // Send 'Gekko starting' message if true
 sendMessageOnStart: false,
   // disable advice printout if it's soft
 muteSoft: false,
 tag: '[GEKKO]',
   // twitter consumer key
 consumer_key: '',
   // twitter consumer secret
 consumer_secret: '',
   // twitter access token key
 access_token_key: '',
   // twitter access token secret
 access_token_secret: ''
};

config.xmppbot = {
 enabled: false,
 emitUpdates: false,
 client_id: 'jabber_id',
 client_pwd: 'jabber_pw',
 client_host: 'jabber_server',
 client_port: 5222,
 status_msg: 'I\'m online',
 receiver: 'jabber_id_for_updates'
}

config.campfire = {
 enabled: false,
 emitUpdates: false,
 nickname: 'Gordon',
 roomId: null,
 apiKey: '',
 account: ''
}

config.redisBeacon = {
 enabled: false,
 port: 6379, // redis default
 host: '127.0.0.1', // localhost
   // On default Gekko broadcasts
   // events in the channel with
   // the name of the event, set
   // an optional prefix to the
   // channel name.
 channelPrefix: '',
 broadcast: [
   'candle'
 ]
}

config.slack = {
 enabled: false,
 token: '',
 sendMessageOnStart: true,
 muteSoft: true,
 channel: '' // #tradebot
}

config.ifttt = {
 enabled: false,
 eventName: 'gekko',
 makerKey: '',
 muteSoft: true,
 sendMessageOnStart: true
}

config.candleWriter = {
 enabled: false
}

config.adviceWriter = {
 enabled: false,
 muteSoft: true,
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                       CONFIGURING ADAPTER
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.adapter = 'sqlite';

config.sqlite = {
 path: 'plugins/sqlite',

 dataDirectory: 'history',
 version: 0.1,

 journalMode: require('./web/isWindows.js') ? 'DELETE' : 'WAL',

 dependencies: []
}

 // Postgres adapter example config (please note: requires postgres >= 9.5):
config.postgresql = {
 path: 'plugins/postgresql',
 version: 0.1,
 connectionString: 'postgres://user:pass@localhost:5432', // if default port
 database: null, // if set, we'll put all tables into a single database.
 schema: 'public',
 dependencies: [{
   module: 'pg',
   version: '6.1.0'
 }]
}

// Mongodb adapter, requires mongodb >= 3.3 (no version earlier tested)
config.mongodb = {
 path: 'plugins/mongodb',
 version: 0.1,
 connectionString: 'mongodb://localhost/gekko', // connection to mongodb server
 dependencies: [{
   module: 'mongojs',
   version: '2.4.0'
 }]
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                       CONFIGURING BACKTESTING
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// Note that these settings are only used in backtesting mode, see here:
// @link: https://gekko.wizb.it/docs/commandline/backtesting.html

config.backtest = {
 daterange: 'scan',
// daterange: {
//   from: "2018-03-01",
//   to: "2018-04-28"
//},
 batchSize: 50
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//                       CONFIGURING IMPORTING
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

config.importer = {
 daterange: {
   // NOTE: these dates are in UTC
   from: "2017-11-01 00:00:00",
   to: "2017-11-20 00:00:00"
 }
}

// set this to true if you understand that Gekko will
// invest according to how you configured the indicators.
// None of the advice in the output is Gekko telling you
// to take a certain position. Instead it is the result
// of running the indicators you configured automatically.
//
// In other words: Gekko automates your trading strategies,
// it doesn't advice on itself, only set to true if you truly
// understand this.
//
// Not sure? Read this first: https://github.com/askmike/gekko/issues/201
config['I understand that Gekko only automates MY OWN trading strategies'] = false;

module.exports = config;




save the config. you can now>>>>>save as >>>config.js
or:

Code:
myStratName_7min_myCoinPair_myBlaBla.js


you can read about how to modify your config.js here:
gekko cli version tutorial


RE: [TUT] STRATEGIE #5 dynamique stoploss [SHARE] - ankasem - 06-21-2018

thank you


RE: [TUT] STRATEGIE #5 strategie CLI-config settings !!! - MrKyle - 08-14-2018

Good Morning,

First of all, thank you so much for putting this information out there.I am super new to Gekko, and have some JavaScript experience, but am having trouble getting everything set up and backtested. I'm hoping you can help me out!So far, I have installed nodeJS, Gekko, and the tulip/talib indicators. I have also copied and pasted your code from the nodeJS part of the module into a my own config file, and it does run when I do a "node gekko.js --config .\dynamiqueStopLossCommandLine.js--backtest", but it seems as though it is only using the MACD indicator. When I looked at the config file, I see in the advisor section that it is just referencing MACD. I tried to change this to the filename of the strategy I copied into the strategy folder of Gekko, but then I get an error that states Cannot read property 'RSI' of undefined.

Any help you could provide would be greatly appreciated!!!!!

I am very excited yet humbled by my entry into the trading world.

Sincerely,

Kyle


RE: [TUT] STRATEGIE #5 dynamique stoploss [SHARE] - Justaotheruser - 08-14-2018

try this 'node gekko --config (yourconfig.js file) --backtest' Make sure that you have all space between the letters. you have "node gekko.js --config .\dynamiqueStopLossCommandLine.js--backtest" There are no space's between \dynamiqueStopLossCommandLine.js and --backtest

which os do you use ?


RE: [TUT] STRATEGIE #5 dynamique stoploss [SHARE] - PGTART - 09-15-2019

I like the background thinking here
I wonder if stddev monitoring on trades would work. EA price still in uptrend but on fading trend where trades decrease go short.

Might not be a stoploss function rather a profit taker. I rather have profit takers firing then stoploss.