Beginer help / Simple RSI strategy
Mike last edited by
Very beginner question, I wanted to build a very simple RSI strategy which is long/short. In other words, it does reversals so we are always in position. Can anyone guide me how to begin, so far I'm able to do long-only strategy but struggling with coding reversal logic
def __init__(self): self.rsi = bt.indicators.RSI_SMA(self.data.close, period=14) def next(self): if not self.position: if self.rsi < 30: self.buy(size=100) else: if self.rsi > 70: self.sell(size=100)
sellwhen you are in the market, use
close(which obviously closes the existing position)
And use the
> 70comparisons as the entry points if you are not in the market.