03-06-2018, 06:12 PM
(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...
it is possible to have multiple prices to watch ?