Overall Statistics
Total Trades
13
Average Win
1.08%
Average Loss
0%
Compounding Annual Return
84.866%
Drawdown
5.100%
Expectancy
0
Net Profit
6.726%
Sharpe Ratio
3.506
Probabilistic Sharpe Ratio
73.972%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.249
Beta
0.887
Annual Standard Deviation
0.159
Annual Variance
0.025
Information Ratio
2.776
Tracking Error
0.076
Treynor Ratio
0.63
Total Fees
$13.00
Estimated Strategy Capacity
$48000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
#region imports
from AlgorithmImports import *
#endregion
# MACD, EMA(MACD), MACD.Signal

MA_FAST =  12; MA_SLOW = 26; MA_SIGNAL = 9; TYPE = "Exponential"

class MACD_SignalCrossover(QCAlgorithm):

        def Initialize(self):
            self.SetStartDate(2008, 1, 19)  
            self.SetEndDate(2008, 2, 26)
            self.SetCash(1000)  
            self.AddEquity("SPY", Resolution.Minute).Symbol               
            self.AddRiskManagement(MaximumUnrealizedProfitPercentPerSecurity(0.01))
            self.macd = self.MACD("SPY", MA_FAST, MA_SLOW, MA_SIGNAL, MovingAverageType.Exponential, Resolution.Minute )
            self.macd_ema = IndicatorExtensions.EMA(self.macd, MA_SIGNAL)
            self.SetWarmUp(MA_SLOW*5)

            
        def OnData(self, data):
        
            if not self.macd_ema.IsReady: return   
            
            macd = self.macd.Current.Value
            macd_signal = self.macd.Signal.Current.Value 
            macd_signal_2 = self.macd_ema.Current.Value
            
            self.Plot("MACD", "macd_signal", self.macd.Signal.Current.Value)
            self.Plot("MACD", "macd_ema", self.macd_ema.Current.Value)
            self.Plot("MACD", "Zero", 0)            
            
               
            if  macd > macd_signal:
                self.SetHoldings("SPY", 1)