| Overall Statistics |
|
Total Trades 101 Average Win 16.14% Average Loss -6.51% Compounding Annual Return 57.365% Drawdown 61.800% Expectancy 0.456 Net Profit 462.606% Sharpe Ratio 1.093 Probabilistic Sharpe Ratio 37.985% Loss Rate 58% Win Rate 42% Profit-Loss Ratio 2.48 Alpha 0.594 Beta -0.325 Annual Standard Deviation 0.505 Annual Variance 0.255 Information Ratio 0.761 Tracking Error 0.553 Treynor Ratio -1.696 Total Fees $966.51 Estimated Strategy Capacity $12000000.00 Lowest Capacity Asset TQQQ UK280CGTCB51 |
# MACD Signal Delta Percent simplified
class MACDTrendAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2018, 1, 1)
self.SetEndDate(2021, 10, 22)
self.SetCash(25000)
self.stock = self.AddEquity("TQQQ", Resolution.Minute)
# self.stock.SetDataNormalizationMode(DataNormalizationMode.Raw)
self.symbol = self.stock.Symbol
self.macd = self.MACD(self.symbol, 6, 35, 6, MovingAverageType.Exponential, Resolution.Daily)
self.PlotIndicator("MACD", True, self.macd, self.macd.Signal)
self.PlotIndicator("TQQQ", self.macd.Fast, self.macd.Slow)
self.SetWarmUp(5*41, Resolution.Daily)
self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(0.10))
def OnData(self, data):
if self.IsWarmingUp or not self.macd.IsReady: return
tolerance = 0.0025
holdings = self.Portfolio[self.symbol].Quantity
signalDeltaPercent = (self.macd.Current.Value - self.macd.Signal.Current.Value)/self.macd.Fast.Current.Value
if holdings <= 0 and signalDeltaPercent > tolerance:
self.SetHoldings(self.symbol, 1.0)
elif holdings >= 0 and signalDeltaPercent < -tolerance:
self.SetHoldings(self.symbol, -1.0)