[Bounty] Hiring someone to write a simple Strategy
#19
(02-24-2018, 08:14 PM)ManuManu Wrote: Here is something that should work :

Create a aroundPrice.js, and put it in your gekko/strategies folder :
Code:
var log = require('../core/log');

// Let's create our own strat
var strat = {};

// Prepare everything our method needs
strat.init = function() {
 this.input = 'candle';
 this.currentTrend = 'neutral';
 this.requiredHistory = 0;
 
 this.priceToWatch = this.settings.price_to_watch;
 this.percentUpper = this.settings.percentUpper;
 this.percentLower = this.settings.percentLower;
}

// Based on the newly calculated
// information, check if we should
// update or not.
strat.check = function(candle)
{
    if(this.currentTrend === 'neutral')
    {
        var lowLimit = this.priceToWatch *  ( 1 - this.percentLower/100.0 );
        if ( candle.close < lowLimit )
        {
            this.advice('long');
            this.currentTrend = 'long';
            log.debug("Going long at " + candle.close + " - under : " + lowLimit );
        }
    }
    if (this.currentTrend === 'long')
    {
        var highLimit = this.priceToWatch * ( 1 + this.percentUpper / 100.0);
        if ( candle.close > highLimit )
        {
            this.currentTrend = 'neutral';
            this.advice('short');
            log.debug("Going short at " + candle.close + " - above : " + highLimit );
        }
    }
}


module.exports = strat;


Then create a aroundPrice.toml file and put it into the gekko/config/strategies folder :
Code:
price_to_watch = 10
percentUpper = 10
percentLower = 10


Set the price you want, the upper and lower percentage thresholds,
And that's it...


Not sure it really deserve a bounty, though !


ManuManu

Ps : I tried it on ETH/USDT Binance, from 01/01/2018 to 1st of february, with 1000 to watch +/- 5%, and it gave me +116% in backtest...


ManuManu, this works in concept, but the price needs to be set at the current price and to update as it moves - is this possible?
Many thanks!
  Reply


Messages In This Thread
RE: [Bounty] Hiring someone to write a simple Strategy - by rff - 04-10-2018, 11:10 AM

Forum Jump:


Users browsing this thread: