Last active
June 28, 2020 09:08
-
-
Save saleh-old/f0da74f778249378064c272a6fc2f665 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 = self.high | |
stop = entry - ta.atr(self.candles)*3 | |
qty = utils.risk_to_qty(self.capital, 5, entry, stop, fee_rate=self.fee_rate) | |
# highest price of the last 20 bars | |
last_20_highs = self.candles[-20:, 3] | |
previous_high = np.max(last_20_highs) | |
self.buy = qty, entry | |
self.stop_loss = qty, stop | |
self.take_profit = qty/2, previous_high | |
def go_short(self): | |
entry = self.low | |
stop = entry + ta.atr(self.candles) * 3 | |
qty = utils.risk_to_qty(self.capital, 5, entry, stop, fee_rate=self.fee_rate) | |
# lowest price of the last 20 bars | |
last_20_lows = self.candles[-20:, 4] | |
previous_low = np.min(last_20_lows) | |
self.sell = qty, entry | |
self.stop_loss = qty, stop | |
self.take_profit = qty / 2, previous_low |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment