Overall Statistics
Total Trades
421
Average Win
1.25%
Average Loss
-0.81%
Compounding Annual Return
14.181%
Drawdown
11.100%
Expectancy
0.368
Net Profit
94.149%
Sharpe Ratio
1.062
Probabilistic Sharpe Ratio
51.318%
Loss Rate
46%
Win Rate
54%
Profit-Loss Ratio
1.54
Alpha
0.071
Beta
0.246
Annual Standard Deviation
0.095
Annual Variance
0.009
Information Ratio
-0.151
Tracking Error
0.149
Treynor Ratio
0.41
Total Fees
$17149.48
Estimated Strategy Capacity
$280000000.00
Lowest Capacity Asset
IEF SGNKIKYGE9NP
# Trading ATR with Indicator Extensions Delay

# ------------------------------------------------------
STOCK = 'SPY'; BOND = 'IEF'; ATR_PERIOD = 10; DELAY = 4;
# ------------------------------------------------------

class ATRconfirmation(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2017, 3, 26)  
        self.SetEndDate(2022, 3, 25)  
        self.SetCash(1000000)   
        self.stock = self.AddEquity(STOCK, Resolution.Daily).Symbol
        self.bond = self.AddEquity(BOND, Resolution.Daily).Symbol
        self.SetWarmUp(ATR_PERIOD + 1, Resolution.Daily)
        self.atr = self.ATR(self.stock, ATR_PERIOD, Resolution.Daily)
        self.delayed_atr = IndicatorExtensions.Of(Delay(DELAY), self.atr)

       
    def OnData(self, data):
        if self.IsWarmingUp or not self.delayed_atr.IsReady: return   

        if not self.Portfolio[self.stock].Invested:
            if self.atr.Current.Value <= self.delayed_atr.Current.Value:
                self.SetHoldings(self.stock, 1.0)
                self.SetHoldings(self.bond, 0)
                
        elif self.Portfolio[self.stock].Invested:    
            if self.atr.Current.Value > self.delayed_atr.Current.Value:
                self.SetHoldings(self.stock, 0)    
                self.SetHoldings(self.bond, 1.0)