Hello,
I just joined myself. I've played around with python in the past so I'll give this a try.
def initialize(context):
context.goog = sid(26578) #Google
context.max_notional = 1000000.1 #upper trade limit
context.min_notional = -1000000.0 #lower trade limit
def handle_data(context, data):
#Calculate EMAs
lead = data[context.goog].mavg(10)
lag = data[context.goog].mavg(100)
#Price of google over time
price = data[context.goog].price
#Calculate Position
notional = context.portfolio.positions[context.goog].amount * price
#Go long when lead>lag and short when lead<lag
if lead < lag and notional > context.min_notional:
order(context.goog,-100) #short 100 shares
elif lead > lag and notional < context.max_notional:
order(context.goog,+100) #long 100 shares
#Plot Price and EMAs
record(Close = price, Lead = lead, Lag = lag)
Let me know when you get the RSI going.
-Marc