Hello Community,
I was wondering if someone can make me a skeleton code I can try here where I will be able to easy modify my EMA crosses and time frames. I would like to start by testing a 13/3 EMA CROSS on a 1 minute chart, backtesting at least 6 months to 1 year. I would like the code to only recognize the ema cross once the candle has closed. So at the end of each candle did the signal change from long to short for example, if yes, then send signal at close of candle or open of very next candle only.
Paul Saunders
Michael Handschuh
Chris Grosvenor
Avishek Nagi
I modified the Moving Average templet. This algo Buy $aapl stock if EMA 89 is above SMA 140, and Close the trade if the opposite occurs.
Since I am new to programming, I suspect I there might be some issues that is not apparent to me.
Any input from the Quantconnect community?
Thanks for any input.
Avi
JayJayD
Avi, the issue with this algorithm has nothing to do with your programming skills, instead the problem here is the selection bias. Basically, you made a long strategy with a bullish stock like AAPL in the period under study. You can achieve a higher Net Profit if you just buy the stock at the beginning of the strategy.
Avishek Nagi
Great Thanks JayJayD for your response. I agree there is selection bias issue. I wanted to create a starting point by testing different stocks, APPL just came to mind. Next step will be to test this strategy on portfolio of stock, and measure its performance to SPY.
I don't quite understand how to work with portofio of stocks yet, but will dig deeper.
If you or anyone elso have any tips regarding coding protfolio of stocks, please share them.
Thanks
JayJayD
Avi, you can use Dictionaries and make every module of you algorithm an object for each one of the securities.
I made this example with a module for teh crossing moving averages and another module for risk managment.
The cross moving average module is the signal generator (buy - sell) and a instance is declared for each one of the securities.
Finally, don't forget to check the QCUniversity, there are tons of great examples.
Chris Grosvenor
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!