Overall Statistics
Total Trades
965
Average Win
0%
Average Loss
-0.66%
Compounding Annual Return
-100.000%
Drawdown
95.200%
Expectancy
-1
Net Profit
-95.157%
Sharpe Ratio
-0.369
Probabilistic Sharpe Ratio
0.000%
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.434
Beta
-4.107
Annual Standard Deviation
2.709
Annual Variance
7.339
Information Ratio
-0.49
Tracking Error
2.752
Treynor Ratio
0.243
Total Fees
$965.00
Estimated Strategy Capacity
$2900000.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.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)
                self.StopMarketOrder("SPY", -1, 1.01 * self.Securities["SPY"].Close)