Hi everyone,
I am new to Quantopian, but have previous C++ experience. I am trying to build an algorithm that compares different SMAs. The problem is I don't think I am using the right coding, or the coding I interpreted from the Quant 2 transition guide wasn't correctly represented.
Anyhow, I am thinking that the proper way to call the SMAs for any price history, in minute mode, would now be:
price_history = data.history(context.security,'close',50,'1m')
sma10 = price_history[-10:].mean()
sma20 = price_history[-20:].mean()
sma50 = price_history[-50:].mean()
The above is just an example of what I have tried (please note: I have moved the colon to the left and taken it out and I still have a problem). So the problem is that when I compare my buy and sell timing in the logs to a stock chart's SMA overlays, the algorithm is not buying or selling at the right time. For instance, the start of a bullish trend on the price is when the SMA20 crosses above the SMA50, so I try and buy to hold until selling when the SMA10 crosses below the SMA20. Then start the whole process over again.
With the above coding, the algorithm buys when the SMA20 is below the SMA50, though is tell it order(context.security,1) when SMA20 > SMA50. Any help would be appreciated, I'm kind of losing hair over this...
Thank you all.
Danny