EMA Crossover LONG/SHORT

Back

Hello Quant Community,

I have recently been working on a EMA crossover strategy that implements quite a few other indicators but I have recently run into an issue.

My issue is when I try to short stocks, so I removed all strategy elements besides the EMAs because that is what is causing the issue. I am sure its some simple logic but frankly I need a fresh set of eyes on it.

So I am trying to go LONG on a 13/49EMA Crossover when price is above a 220EMA, and short when there is a 49/13EMA Crossover below the 220EMA.

I know an EMA strategy standing alone is rough to make profitable, however I believe with other analyses and Profit/Loss orders I would like to try to make it profitable. 

Eventually I would like to implement my complete strategy in a Universe Filter but thats a post for another day. And the code is currently set up to take a full portfolio and buy based on portfolio size.

MY ISSUE:

So everything works fine for the 13/49EMA Crossover above the 220EMA, however when there is a 49/13EMA when price is below 220EMA it seems to buy and sell every minute. I am fairly certain its a simple logic thing, thats why I implemented so many plots for visualization when I use other indicators and analysis as well. However the plotting doesnt come up great in an attached backtest so feel free to throw it in your own Node.

Any help or ideas would be greatly appriciated!

Update Backtest








 
0

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.


P.S. Ignore the plot for short selling the plots are swapped for the crossovers under 220EMA.

0

I believe these purchases are simply very low quantity orders that are not effecting the success too much so I may just continue with what I have.

0

Hi Locke,

SetHoldings will sometimes make trades to rebalance the portfolio to reach the target holdings % as the price of the asset changes, and with the current logic, either a SetHoldings, which may cause this rebalancing, or a liquidation will occur. To prevent these trades, we can check if we already hold a position in the direction we want to purchase. These changes can be seen in the attached backtest, and there are now no trades every hour. Note, instead of SetHoldings to 0, we can call Liquidate, and this is also reflected in the attached backtest.

Best,
Shile Wen

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed