| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -1.298 Tracking Error 0.122 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
# Three ways to get a normalized ATR
class MuscularGreenAlbatross(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 9, 1)
self.SetEndDate(2021, 10, 7)
self.stock = self.AddEquity("SPY", Resolution.Daily).Symbol
self.SetWarmUp(15, Resolution.Daily)
self.atr = self.ATR(self.stock, 14, MovingAverageType.Simple, Resolution.Daily)
self.yest_close = self.Identity(self.stock, Resolution.Daily, Field.Close)
self.atr_norm_2 = IndicatorExtensions.Over(self.atr, self.yest_close)
def OnData(self, data):
if self.IsWarmingUp or not self.atr.IsReady or not self.atr_norm_2.IsReady: return
atr_norm_1 = float(self.atr.Current.Value / self.yest_close.Current.Value)
atr_norm_2 = float(self.atr_norm_2.Current.Value)
# atr_norm_3 =
self.Plot("ATR", "atr_norm_1", atr_norm_1)
self.Plot("ATR", "atr_norm_2", atr_norm_2)
# self.Plot("ATR", "atr_norm_3", atr_norm_3)
class symbolData:
def __init__(self, algo, ticker):
self.symbol = algo.AddEquity(ticker, Resolution.Daily).Symbol
self.atr = algo.ATR(self.symbol, 14, MovingAverageType.Simple, Resolution.Daily)
self.id = algo.Identity(self.symbol, Resolution.Daily, Field.Close)
self.atrOverPrice = IndicatorExtensions.Over(self.atr, self.id)
# Warm up ATR
history = algo.History(self.symbol, 15, Resolution.Daily)
for bar in history.itertuples():
tradeBar = TradeBar(bar.Index[1], bar.Index[0], bar.open, bar.high,
bar.low, bar.close, bar.volume)
self.atr.Update(tradeBar)
# Warm up Identity, since it should be using 2-day-prior close price
history = algo.History(self.symbol, 2, Resolution.Daily).iloc[0]
self.id.Update(pd.to_datetime(history.name[1]), history.close)