Created
June 9, 2020 07:59
-
-
Save saleh-old/7569cad1b10dee874c494ee4a47d9120 to your computer and use it in GitHub Desktop.
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
def go_long(self): | |
# entry: the high of the current candle | |
entry = self.high | |
stop = entry - ta.atr(self.candles)*3 | |
qty = utils.risk_to_qty(self.capital, 5, entry, stop) | |
last_20_highs = self.candles[-20:, 3] | |
previous_high = np.max(last_20_highs) | |
self.buy = qty, entry | |
self.stop_loss = qty, stop | |
# (first) take-profit: the high of the last 20 candles | |
self.take_profit = qty/2, previous_high |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment