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
-0.848
Tracking Error
0.223
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
# TaLib DEMA Delayed

from AlgorithmImports import *
import numpy as np
import talib 

STOCK = 'SPY'; PERIOD = 50; DELAY = 10;

class TaLibDEMA(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 31)
        self.SetEndDate(2021, 10, 20) 
        self.SetWarmUp(5*PERIOD, Resolution.Daily)
        self.stock = self.AddEquity(STOCK, Resolution.Daily).Symbol
        self.rollingWindow = RollingWindow[TradeBar](5*PERIOD)
        self.Consolidate(self.stock, Resolution.Daily, self.CustomBarHandler)
        
        
    def CustomBarHandler(self, bar):
        self.rollingWindow.Add(bar)         
        if self.IsWarmingUp: return
        if not self.rollingWindow.IsReady: return
        closes = np.flipud(np.array([self.rollingWindow[i].Close for i in range(5*PERIOD)]))

        talib_dema = talib.DEMA(closes, PERIOD)

        self.Plot("Indicator","talib_dema", talib_dema[-1])
        self.Plot("Indicator", "talib_dema_delayed", talib_dema[-DELAY])
        self.Plot("Indicator", "talib_dema_mean", talib_dema[-DELAY:].mean())