first of all, after having some issues with older gekko versions the current one is working like a charm. Thanks for all the great work!
I created some strategies that work fine and sure, after successfully testing more deeply I will share those here...
For my next "project" I want to create a trading strategy that works great in FOREX markets to verify if it can be used for crypto currencies, too. This strategy is based on two SMAs with the same period but calculated based on the HIGH and LOW values of the candles.
And that's why I kindly ask the community to point me to the right direction:
As I've seen all indicators (gekko, talib, tulip) are calculated based on the CLOSE values (please correct me if I'm wrong).
Is there a way to do what I explained above? If yes, how can this be achieved?
My knowledge of linux, apache and nodejs is not that great.
But has someone a good detail description for me, how I can run it on an apache server (linux)?
Hi Mike and others, and first really thank you for the great work on Gekko bot and its additions !
Perhaps i misunderstood something, and perhaps somebody could explain why the CCI results are not the same as i can see on tradingview with the same settings.
Here is what i did to verifiy gekko CCI indicator value against Tradingview CCI value on same period :
1/ Choose a pair (NEO/ETH) on an exchange (BINANCE) and import 1 month data
2/ Choose an indicator (CCI), a candle size (4 hours) and history size (20 everywhere, so supposed to be 20 * 4hours candle if i'm right)
3/ Make the corresponding graph on tradingview :
4/ Just modify the CCI.js strat file to write date and cci value in a csv file on each candle :
5/ Launch backtest (UI or CLI) and compare values to see they not correspond
examples :
on 2018-02-05 5:00, tradingview CCI was -58, but for Gekko it was -93 !?
on 2018-02-06 5:00, tradingview CCI was -176, but for Gekko it was -38 !?
on 2018-02-07 9:00, tradingview CCI wast +170, but for Gekko it was +134
Thanks if somewhone can explain me why or what i did wrong, all is configured with 4hours candle, 20 history : or prhaps on Tradingview it is 20 DAYS history ?
So to have same results in Gekko i should put 280 (4*6*20) to have 20 days ?
Hi friends, I'm looking for someone who can help me with the implementation of my first gekko strategy. I managed to add all the necessary files to the gekko directory so that I do not give an error once started. the problem is that the bot makes zero trade. [node version:9.5.0 ; npm version:5.6.0; gekko version:0.5.12] these are the files I used:
var Indicator = function(BBSettings) {
this.input = 'price';
this.settings = BBSettings;
// Settings:
// TimePeriod: The amount of samples used for the average.
// NbDevUp: The distance in stdev of the upper band from the SMA.
// NbDevDn: The distance in stdev of the lower band from the SMA.
this.prices = [];
this.diffs = [];
this.age = 0; // age = Warm Up Period
this.sum = 0;
this.sumsq = 0;
this.upper = 0;
this.middle = 0;
this.lower = 0;
}
Indicator.prototype.update = function(price) {
var tail = this.prices[this.age] || 0; // oldest price in window
var diffsTail = this.diffs[this.age] || 0; // oldest average in window
this.prices[this.age] = price;
this.sum += price - tail;
this.middle = this.sum / this.prices.length; // SMA value
// your code:
// this.diffs[this.age] = (price - this.middle);
// customized code (see formula), we have to build a math.pow:
this.diffs[this.age] = Math.pow((price - this.middle), 2);
// your code:
// var stdev = Math.sqrt(this.sumsq) / this.prices.length;
// customized code (see formula), we have to build a math.sqrt over the whole expression:
var stdev = Math.sqrt(this.sumsq / this.prices.length);
var macd = this.indicators.macd;
var diff = macd.diff;
var signal = macd.signal.result;
var BB = this.indicators.bb;
var price = candle.close;
var macddiff = this.indicators.macd.result;
//BB
var BB = this.indicators.bb;
//BB.lower; BB.upper; BB.middle are your line values
var MACDsaysBUY = macddiff > this.settings.thresholds.up;
var MACDsaysSELL = macddiff <= this.settings.thresholds.down;
var StochRSIsaysBUY = this.stochRSI < this.settings.thresholds.low;
var StochRSIsaysSELL = this.stochRSI >= this.settings.thresholds.high;
var BBsayBUY=price >= (BB.middle-(BB.middle-BB.lower)/4);
var BBsaySELL=price <= BB.lower; //>= BB.upper || price <= BB.lower
method.check = function(candle) {
//MACD
var macddiff = this.indicators.macd.result;
//BB
var BB = this.indicators.bb;
//BB.lower; BB.upper; BB.middle are your line values
var price = candle.close;
//buy when stochRSI in low and MACD in up
//short->sell, long->buy
var MACDsaysBUY = macddiff > this.settings.thresholds.up;
var MACDsaysSELL = macddiff <= this.settings.thresholds.down;
var StochRSIsaysBUY = this.stochRSI < this.settings.thresholds.low;
var StochRSIsaysSELL = this.stochRSI >= this.settings.thresholds.high;
var BBsayBUY=price >= (BB.middle-(BB.middle-BB.lower)/4);
var BBsaySELL=price <= BB.lower; //>= BB.upper || price <= BB.lower
if(MACDsaysSELL && StochRSIsaysSELL) {
// new trend detected
if(this.trend.direction !== 'high')
this.trend = {
duration: 0,
persisted: false,
direction: 'high',
adviced: false
};
this.trend.duration++;
log.debug('In high since', this.trend.duration, 'candle(s)');
hi IP Access Restriction: Restrict access to trusted IPs only (Recommended) IP Access Restriction: Restrict access to trusted IPs only (Recommended) rope changed
1. Allow settings to be ranges of min/max so instead of this in the 'Parameters' (UI) @ backtest:
short = 20
long = 50
...it could instead be this:
short = 20,40:5
long = 50,100:10
where X,Y = min/max
and :Z = stepping (in what amounts of steps this value should be changed; this since one woulnd't want to change every possible value by e.g. 1)
Above would simply translate to:
short = min: 20, max: 40, stepping: 5
long = min: 50, max: 100, stepping: 10
2. If there's ranges etc: Run backtests and change value(s) each time (if not, just do a regular backtest)
3. Have the ability to define max amount of runs (where -1 = infinite (or until number of tests runs out); custom setting that works for all strategies e.g. ga_runs = -1
4. Output best performing results -or- output the results that beat the market in some sorted .log or .csv (the latter for easy import/manipulation in 3rd party app e.g. Excel or whatever)
5. Output runs to the log() (so that one know what's happening etc...)
Doable in a reasonably amount of time?
Problem is that the GA-stuff that exist now is tedious, doesn't really work, requires other stuff that doesn't work etc etc ... (tl;dr -- tedious).
I developed my working strategy and I like how it works good sometimes.
Here there are some problems with my usage of Gekko (trading bot with API from exchanges):
1) I save the last price I bought/sold like:
Code:
this.lastprice = candle.close;
This is a big problem when you buy/sell at a price xx% (where xx is big) higher/lower from the price that triggered the advice.
Example:
Advice: buy @0.00015 -> lastprice = 0.00015 but then it buys @0.00019 -> sell @0.00017 -> I expect +0.00002 but I'm like -0.00002.
Is there a solution? Is there the possibility to get the last price traded instead of the way I use?
2) I also would like to stop orders repetition (for example: if there's a long advice when price is 0.00015 and then price goes to 0.00030 while the order is not yet satisfied, I would like to cancel the order, not changing it to buy @0.00030). Is it possible?
3)Am I right to use advices (this.advice("long"); / this.advice("short") even if I'm using trading bot and not paper trader? Or is it possible to use something more useful? For example:
3.a) Is it possible to suggest prices instead of using the best to buy/sell?
3.b) Is it possible to force some (or any, but I would prefer just some) order to "taker" instead of "maker" (market price usage) in Gdax?
Sorry for my bad english, hope everything is clear!
Sorry if there is an obvious solution but I'm not a developer
Thank you for your software and your time, you already made a fantastic work!