Overall Statistics
Total Trades
1
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
Tracking Error
0
Treynor Ratio
0
Total Fees
$1.85
Estimated Strategy Capacity
$2600000000.00
Lowest Capacity Asset
MNQ Y1VKEF59AV41
# region imports
from AlgorithmImports import *
# endregion

class FatGreenBull(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2022,7,12)
        self.SetEndDate(2022,7,12)

        # Set this to False to force it to stay on minute resolution
        self.AllowTicks = False

        self.future = Futures.Indices.MicroNASDAQ100EMini
        self._continuousContract = self.AddFuture(self.future,
                Resolution.Minute,
                dataNormalizationMode=DataNormalizationMode.Raw,
                dataMappingMode=DataMappingMode.OpenInterest,
                contractDepthOffset=0)
        self.commod = self._continuousContract.Symbol
        self.TicksEnabled = False

        self.TriggerOrder = False
        self.TriggerMinuteResolution = False

        self.Log("Done initialization")

    def OnData(self, data: Slice):

        if self.TriggerOrder:
            self.TriggerOrder = False
            self.MarketOrder(self._continuousContract.Mapped, 1)

        if self.TriggerMinuteResolution and self.TicksEnabled:
            self.TriggerMinuteResolution = False
            self.DisableTicks()

        if self.Time.hour == 9 and self.Time.minute == 37 and not self.TicksEnabled:
            # Enter tick resolution
            self.EnableTicks()
            # Do the market order on the next update
            self.TriggerOrder = True

        if self.Time.hour == 9 and self.Time.minute == 39 and self.TicksEnabled:
            # Exit tick resolution on the next update
            self.TriggerMinuteResolution = True

    def EnableTicks(self):
        if not self.AllowTicks: return
        if not self.TicksEnabled:
            self.RemoveSecurity(self.commod)
            self._continuousContract = self.AddFuture(self.future,
                    Resolution.Tick,
                    dataNormalizationMode=DataNormalizationMode.Raw,
                    dataMappingMode=DataMappingMode.OpenInterest,
                    contractDepthOffset=0)
            self.commod = self._continuousContract.Symbol
            self.TicksEnabled = True

    def DisableTicks(self):
        if self.TicksEnabled:
            self.RemoveSecurity(self.commod)
            self._continuousContract = self.AddFuture(self.future,
                    Resolution.Minute,
                    dataNormalizationMode=DataNormalizationMode.Raw,
                    dataMappingMode=DataMappingMode.OpenInterest,
                    contractDepthOffset=0)
            self.commod = self._continuousContract.Symbol
            self.TicksEnabled = False