Long Only - Moving Average Crossover - Manual Universe (free)

Long Only - Moving Average Crossover - Manual Universe (free)

Here's a FREE ALGO for you, simply hit the CLONE ALGORITHM button below!

This is an implementation of a classic market timing technique using the crossover of two moving averages.

Universe: Manual input of tickers.

Alpha: Go Long when the Short Period Moving Average crosses above the Long Period Moving Average, and move into cash when it crosses below.

Portfolio: Equally Weighted portfolio (investing the same amounts in each security).

Execution: Immediate Execution with Market Orders.

Research: This project also includes a research file with explanation of the Alpha logic.

Ideas to try (user-defined inputs in the main.py script):

  • Play with the SetStartDate and SetEndDate dates to change the period of backtest. Does it time the 2008 crisis well?
  • Increase the trading frequency by changing the data resolution from Resolution.Daily to Resolution.Hour or Resolution.Minute
  • Add/change the tickers. For example, to select the FANG stocks simply change this line code tickers = ['FB', 'AMZN', 'NFLX', 'GOOG']
  • Play with the length of the two moving averages. Maybe a faster reaction to market timing could be shortPeriodSMA = 10 and longPeriodSMA = 200 Does it improve the performance?
  • Activate the rebalancing mechanism to ensure the portfolio goes back to equal weighting every so often. The rebalancingParam is set to False by default, but it can be set to a discretionary number of days to rebalance the portfolio. For instance, if you want to rebalance every 30 days simply do rebalancingParam = 30
Do you have a strategy of your own that you would like to backtest and automate? Learn about our consulting services and get in touch at admin@innoquantivity.com

    Found this product useful? You can support this site by making a donation using the link below!