Can someone help me to write this nested SMA method algorithm?
import talib
def initialize(context):
context.stocks = [sid(8554),sid(33652)]
def handle_data(context, data):
high_price = history(bar_count=25, frequency='1d',field='high')
low_price = history(bar_count=25, frequency='1d',field='low')
close_price =history(bar_count=25, frequency='1d',field='close_price')
r = (close_price - low_price)/(high_price - low_price)
up = SMA(r*30,4,1)
mid = SMA(up,3,1)
ground = SMA(mid,2,1)
resistance_line = 80
longtrend = 9*up - 3*mid - 2*ground
Sell if longtrend cross above resistance