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 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
from AlgorithmImports import * class SuperTrendATRStrategy(QCAlgorithm): def Initialize(self): self.SetStartDate(2023, 9, 1) # Set your desired start date self.SetCash(10000) # Set your initial cash balance self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Cash) self.AddFuture(Futures.Indices.MicroSP500EMini)#self.AddFuture("MES", Resolution.Minute) self.AddSecurity(Futures.Indices.MicroSP500EMini, Resolution.Minute)#"MES", Resolution.Minute) self.SetExecution(ImmediateExecutionModel()) # Define SuperTrend parameters self.supertrend = self.STR("MES", 1, 4, MovingAverageType.Wilders, Resolution.Minute) # Schedule the closing of positions at 3:45 PM self.Schedule.On(self.DateRules.EveryDay("MES"), self.TimeRules.At(15, 45), self.CloseAllPositions) # Indicator initialization def OnData(self, data): # Only trade between 8:00 and 15:00 if self.Time.hour < 8 or self.Time.hour > 15: return if self.supertrend.IsReady: if not self.Portfolio.Invested: if self.supertrend.Current.Value > self.Securities["MES"].Close: self.MarketOrder("MES", 1) elif self.supertrend.Current.Value < self.Securities["MES"].Close: self.MarketOrder("MES", -1) else: if self.supertrend.Current.Value > self.Securities["MES"].Close: self.Liquidate("MES") elif self.supertrend.Current.Value < self.Securities["MES"].Close: self.Liquidate("MES") def CloseAllPositions(self): self.Liquidate()