Overall Statistics
Total Trades
150
Average Win
0.27%
Average Loss
-0.12%
Compounding Annual Return
-91.601%
Drawdown
7.800%
Expectancy
-0.874
Net Profit
-7.821%
Sharpe Ratio
-7.579
Probabilistic Sharpe Ratio
0%
Loss Rate
96%
Win Rate
4%
Profit-Loss Ratio
2.14
Alpha
-3.2
Beta
0.608
Annual Standard Deviation
0.122
Annual Variance
0.015
Information Ratio
-49.569
Tracking Error
0.094
Treynor Ratio
-1.516
Total Fees
$150.00
import numpy as np
from System.Drawing import Color

class VerticalTransdimensionalCoreWave(QCAlgorithm):

    def Initialize(self):
        
        self.SetTimeZone("America/New_York")
        self.SetStartDate(2020,9,24)
        self.SetEndDate(2020,10,5)
        self.TQQQ = self.AddEquity("TQQQ", Resolution.Minute)
        self.SetCash(10000)  # Set Strategy Cash
        self.SetWarmUp(350)
        
        self.Firststock = "TQQQ"
        
        #Indicators that can be changed
        self.FirstHMAPeriod = 25
        self.AbsAveragePeriod = 15

        self.UpperLimitX = 1.5
        self.LowerLimitX = -1.5

        self.ShortEMA= 85
        self.LongEMA = 90
        self.CyclePeriod = 10
  
        #HMA Section******************************************
        self.Firsthma = self.HMA(self.Firststock, self.FirstHMAPeriod, Resolution.Minute) #Initializing the Hull Moving Average of the First Stock
        #self.Secondhma = self.HMA(self.Firststock, self.SecondHMAPeriod, Resolution.Minute) #Initializing the Hull Moving Average of the First Stock

        #HMA Value Rate of Change Percent
        self.HMAPercent = IndicatorExtensions.Of(RateOfChangePercent(1), self.Firsthma)
        self.HMAPercent.Updated += self.HMASlopeUpdated
        self.HMAPercentWindow = RollingWindow[float](10)
        self.AbsHMAPercent = SimpleMovingAverage(1)
        self.HMAPercent.Updated += self.UpdateAbsHMAPercent
        self.AbsAveragePercent = IndicatorExtensions.SMA(self.AbsHMAPercent, self.AbsAveragePeriod)
        
        #Plotting****************************************************************
        stockPlot = Chart("Trade Plot")
        stockPlot.AddSeries(Series("Price Close", SeriesType.Line, 0))
        stockPlot.AddSeries(Series("Price Open", SeriesType.Line, 0))
        stockPlot.AddSeries(Series("FirstHMA", SeriesType.Line, 0))
        stockPlot.AddSeries(Series("SecondHMA", SeriesType.Line, 0))
        stockPlot.AddSeries(Series('Buy', SeriesType.Scatter, '$', Color.Green, ScatterMarkerSymbol.Triangle))
        stockPlot.AddSeries(Series('Sell', SeriesType.Scatter, '$', Color.Red, ScatterMarkerSymbol.TriangleDown))
        self.AddChart(stockPlot)
    
    def UpdateAbsHMAPercent(self, sender, updated):
        if not self.HMAPercent.IsReady:
            return
        self.AbsHMAPercent.Update(self.Time, abs(updated.Value))
        if not self.AbsHMAPercent.IsReady:
            return
        
    def HMASlopeUpdated(self, sender, updated):
        self.HMAPercentWindow.Add(updated.Value)
        
    def OnData(self, data): #Where actions take place and you enter in the criteria to follow
        if self.IsWarmingUp: return #warming up the data, starts running the algorithm before the actual start data
        
       
        if not (self.HMAPercentWindow.IsReady): return
        

        self.UpperLimit = self.AbsAveragePercent.Current.Value * self.UpperLimitX
        self.LowerLimit = self.AbsAveragePercent.Current.Value * self.LowerLimitX
        
        if (not self.Portfolio.Invested):
            if self.HMAPercentWindow[0] > self.LowerLimit and self.HMAPercentWindow[1] < self.LowerLimit:
                self.SetHoldings(self.Firststock, 1, True)
                self.Plot("Trade Plot", "Buy", data[self.Firststock].Value)
                StopPrice = self.Securities[self.Firststock].Close
                self.StopMarketOrder(self.Firststock, -self.Portfolio[self.Firststock].Quantity, StopPrice)
        
        if (self.Portfolio.Invested):
            if self.HMAPercentWindow[0] < self.UpperLimit and self.HMAPercentWindow[1] > self.UpperLimit:
                self.Liquidate(self.Firststock)
                self.Plot("Trade Plot", "Sell", data[self.Firststock].Value)
                
        #Plotting******************************************************************
        self.Plot("Trade Plot", "Price Close", data[self.Firststock].Close)
        self.Plot("Trade Plot", "FirstHMA", self.Firsthma.Current.Value)


        self.Plot("Percent", "PercentHMA", self.HMAPercent.Current.Value)
        self.Plot("Percent", "AbsoluteAverage", self.AbsAveragePercent.Current.Value)
        self.Plot("Percent", "Upper", self.UpperLimit)
        self.Plot("Percent", "Lower", self.LowerLimit)