Overall Statistics
Total Trades
81
Average Win
16.73%
Average Loss
-4.99%
Compounding Annual Return
62.711%
Drawdown
38.000%
Expectancy
1.174
Net Profit
538.980%
Sharpe Ratio
1.371
Probabilistic Sharpe Ratio
60.610%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
3.35
Alpha
0.355
Beta
1.054
Annual Standard Deviation
0.36
Annual Variance
0.129
Information Ratio
1.172
Tracking Error
0.309
Treynor Ratio
0.468
Total Fees
$448.28
Estimated Strategy Capacity
$4700000.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).Symbol
        self.macd = self.MACD(self.stock, 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))
        for minute in range(1, 361, 60):
            self.Schedule.On(self.DateRules.EveryDay(self.stock), self.TimeRules.AfterMarketOpen(self.stock, minute), 
                self.trade)


    def trade(self):
        if self.IsWarmingUp or not self.macd.IsReady: return

        tolerance = 0.0025
        holdings = self.Portfolio[self.stock].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.stock, 1.0)
                
        elif holdings > 0 and signalDeltaPercent < -tolerance:
            self.Liquidate(self.stock)