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.559
Tracking Error
0.204
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
import clr
clr.AddReference("System")
clr.AddReference("QuantConnect.Algorithm")
clr.AddReference("QuantConnect.Indicators")
clr.AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
import decimal as d

class QQQAlert(QCAlgorithm):

    def Initialize(self):
        self.symbol = "QQQ"
        self.fast_sma_period = 1
        self.slow_sma_period = 200
        
        
        self.SetStartDate(2021, 1, 1)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.resolution = Resolution.Daily
        self.AddEquity(self.symbol, self.resolution)
        
        
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
        self.SetExecution(ImmediateExecutionModel())
        
        self.fast_sma = self.SMA(self.symbol, self.fast_sma_period, self.resolution)
        self.slow_sma = self.SMA(self.symbol, self.slow_sma_period, self.resolution)
        
        self.SetBenchmark(self.symbol)
        
        coinPlot = Chart('Strategy Equity')
        # On the Trade Plotter Chart we want 3 series: trades and price:
        coinPlot.AddSeries(Series('Benchmark', SeriesType.Line, 0))
        coinPlot.AddSeries(Series('Fast SMA', SeriesType.Line, 0))
        coinPlot.AddSeries(Series('Slow SMA', SeriesType.Line, 0))
        
    def OnData(self, data):
        
        if not self.slow_sma.IsReady:
            return
        
        currentPrice = self.Securities[self.symbol].Close
        
        if currentPrice > self.fast_sma.Current.Value:
            insight = Insight.Price(self.symbol, timedelta(days=25), InsightDirection.Up, None, None, None, weight) # manual insight emission
            self.EmitInsights(insight)
        else:
            insight = Insight.Price(self.symbol, timedelta(days=25), InsightDirection.Down, None, None, None, weight) # manual insight emission
            self.EmitInsights(insight)
            
        self.Plot('Strategy Equity', 'Benchmark', self.Securities[self.symbol].Price)
        self.Plot('Strategy Equity', 'Fast SMA', self.slow_sma.Current.Value)
        self.Plot('Strategy Equity', 'Slow SMA', self.fast_sma.Current.Value)