Last active
October 10, 2018 08:56
-
-
Save askmike/0419e212ca70f595f30bffa65a201080 to your computer and use it in GitHub Desktop.
TP example in a gekko strat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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