Created
November 14, 2021 09:21
-
-
Save dkav6/28075a01b15094a118160182c20f8547 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
class MLStrategy(Strategy): | |
n1=5 | |
n2=10 | |
def init(self): | |
self.sma1 = self.I(SMA, self.data.Close, self.n1) | |
self.sma2 = self.I(SMA, self.data.Close, self.n2) | |
def next(self): | |
if crossover(self.sma1, self.sma2) and self.data.target == 1: | |
self.buy() | |
elif crossover(self.sma2, self.sma1) and self.data.target == 0: | |
self.position.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment