Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-1.02
Tracking Error
0.243
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Indicators")

from System import *
from QuantConnect import *
from QuantConnect.Indicators import *
from QuantConnect.Data import *
from QuantConnect.Data.Market import *
from QuantConnect.Algorithm import *
import numpy as np
from datetime import datetime

class MomentumOfMovingAverage(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2009, 1, 1)  #Set Start Date
        self.SetEndDate(2010, 1, 1)    #Set End Date
        self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol
        
        period = 200
        self.sma200 = SimpleMovingAverage(period)
        self.sma2 = SimpleMovingAverage(period)

            
        mom = MomentumPercent(period)
        # define an indicator that takes the output of the sma and pipes it into our delay indicator
        

        # get the momemntum of sma200
        self.momSMA = IndicatorExtensions.Of(mom, self.sma200)
        self.RegisterIndicator(self.spy, self.momSMA, Resolution.Daily)

        # smooth out momentum
        #self.smoothMom = IndicatorExtensions.Of(self.sma2, self.momSMA)
        #self.RegisterIndicator(self.spy, self.smoothMom, Resolution.Daily)
        
    # OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
    def OnData(self, data):
        if data[self.spy] is None: return

        close = data[self.spy].Close
        
        
        self.PlotIndicator("momSMA", self.momSMA) 
        self.Plot("sma200", self.sma200) 


        self.Plot("close", "Price", close)