Skip to content

Instantly share code, notes, and snippets.

@askmike
Last active October 10, 2018 08:56
Show Gist options
  • Save askmike/0419e212ca70f595f30bffa65a201080 to your computer and use it in GitHub Desktop.
Save askmike/0419e212ca70f595f30bffa65a201080 to your computer and use it in GitHub Desktop.
TP example in a gekko strat
strat.init = function() {
// your stuff
this.tp = false;
}
strat.check = function(candle) {
if(/* your own logic on when to buy */) {
this.advice('long');
// store a reference:
this.tp = candle.close + 10; // example: TP 10 above prive
}
if(this.tp) {
// you might want to take profit, lets check
if(candle.close >= this.tp) {
// price is equal to or above your defined tp price
this.advice('short');
// unset the reference:
this.tp = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment