Overall Statistics
Total Trades
21
Average Win
0.99%
Average Loss
-0.84%
Compounding Annual Return
281.519%
Drawdown
3.400%
Expectancy
-0.132
Net Profit
3.991%
Sharpe Ratio
10.485
Probabilistic Sharpe Ratio
82.360%
Loss Rate
60%
Win Rate
40%
Profit-Loss Ratio
1.17
Alpha
1.728
Beta
0.62
Annual Standard Deviation
0.2
Annual Variance
0.04
Information Ratio
10.917
Tracking Error
0.138
Treynor Ratio
3.379
Total Fees
$52.16
Estimated Strategy Capacity
$27000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
# Trading QC Super Trend Indicator
# --------------------------------------------
STOCK = "SPY";  BAR = 50; ATR = 2; MULT = 0.1;
# --------------------------------------------

class SuperTrendIndicator(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(DateTime(2022, 5, 17, 9, 30, 0))  
        self.SetEndDate(DateTime(2022, 5, 27, 16, 0, 0)) 
        self.SetCash(200000)
        res = Resolution.Minute
        self.stock = self.AddEquity(STOCK, res).Symbol
        consolidator = TradeBarConsolidator(timedelta(minutes = BAR))
        self.Consolidate(self.stock, timedelta(minutes = BAR), self.BarHandler)
        self.st = SuperTrend(ATR, MULT, MovingAverageType.Wilders)
        self.RegisterIndicator(self.stock, self.st, consolidator)
        self.SetWarmUp(5*BAR*ATR, res)
        
    
    def BarHandler(self, consolidated):
        if self.IsWarmingUp: return
        if not self.st.IsReady: return 

        self.Plot(STOCK, "Price", self.Securities[self.stock].Price)
        self.Plot(STOCK, "Super Trend", self.st.Current.Value)

        if self.Securities[self.stock].Price > self.st.Current.Value:     # trend is bullish
            self.SetHoldings(self.stock, 1, True, "Buy Signal")        

        elif self.Securities[self.stock].Price < self.st.Current.Value:   # trend is bearinsh
            self.Liquidate(self.stock, "Sell Signal")