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
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
from datetime import timedelta

class IndicatorTest(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2017,5,25)  #Set Start Date
        self.SetEndDate(2017,11,25)    #Set End Date
        self.SetCash(100000)           #Set Strategy Cash

        self.symbols = [
            #Futures.Indices.SP500EMini,
            "CL",
            "CG",
            "HG",
            "XK",
        ]
        
        self.indicators = {}
        for symbol in self.symbols:
            future = self.AddFuture(symbol, Resolution.Minute)
            future.SetFilter(timedelta(0), timedelta(182))
            
            # Note use of future.Symbol, if we use symbol string we get error regarding unsubbed asset(so use the object instead)
            self.indicators[symbol] = self.SMA(future.Symbol, 3, Resolution.Minute)
            
        self.do_once = True

    def OnData(self, data):
        
        if self.do_once:
            #self.do_once = False
            for asset in self.indicators:
                if self.indicators[asset].Current.Value != 0:
                    self.Log(str(asset) + " : " + str(self.indicators[asset].Current.Value))
                    """
                    # The indicator is always 0? So we get No result and something like this for logs:
                    
                    2017-09-20 00:00:00 Launching analysis for f8b2c854dfa4e655327d474d65a7649d with LEAN Engine v2.4.0.1.2501
                    2017-11-24 17:00:00 Algorithm Id:(f8b2c854dfa4e655327d474d65a7649d) completed in 28.26 seconds at 73k data points per second. Processing total of 2,050,696 data points.
                    """