Hi,
I tried Grok 3 for writing a QC strategy... and I'm so impressed !Sharing with you the strategy it gaves me…
from AlgorithmImports import *
class BTCUSDTrendFollowingAlgorithm(QCAlgorithm):
def Initialize(self):
# Extended backtest period
self.SetStartDate(2020, 1, 1)
self.SetEndDate(2024, 1, 1)
self.SetCash(100000)
# Add BTC/USDC pair
self.symbol = self.AddCrypto("BTCUSDC", Resolution.Daily).Symbol
# Use a 10-day EMA
self.ema = self.EMA(self.symbol, 10, Resolution.Daily)
self.SetWarmUp(10, Resolution.Daily) # Match warm-up to EMA period
# Adjusted parameters
self.stop_loss_percentage = 0.05 # 5% stop-loss
self.allocation_percentage = 0.5 # 50% allocation
def OnData(self, data):
if not self.IsWarmingUp and data.ContainsKey(self.symbol):
price = data[self.symbol].Close
ema_value = self.ema.Current.Value
# Enter trades when not invested
if not self.Portfolio.Invested:
if price > ema_value: # Long
quantity = self.CalculateOrderQuantity(self.symbol, self.allocation_percentage)
self.MarketOrder(self.symbol, quantity)
elif price < ema_value: # Short
quantity = self.CalculateOrderQuantity(self.symbol, -self.allocation_percentage)
self.MarketOrder(self.symbol, quantity)
# Manage existing trades
else:
holding = self.Portfolio[self.symbol]
if holding.Invested:
if holding.Quantity > 0: # Long
stop_price = holding.AveragePrice * (1 - self.stop_loss_percentage)
if price < stop_price:
self.Liquidate(self.symbol)
elif holding.Quantity < 0: # Short
stop_price = holding.AveragePrice * (1 + self.stop_loss_percentage)
if price > stop_price:
self.Liquidate(self.symbol)

Looks really VERY impressive ;-) Maybe that's too much for me.
Mia Alissi
Sources: Bybit Crypto Futures Regression Algorithm, Bitcoin as a Leading Indicator, Momentum Effect In Commodities Futures, Bybit Crypto Regression Algorithm, Opening Range Breakout for Stocks in Play
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
FemtoTrader
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!