Shared conversation
TQQQ SMA Crossover Strategy and Portfolio Analysis
Explore a detailed analysis of a TQQQ SMA crossover strategy, including portfolio creation, backtesting over multiple timeframes, and a refined Pine Script implementation for trading.
Read the conversation below. Open the interactive view for charts, attachments, and continuing this conversation.
Aurora
Hello. Would you like to use GPT Stock Reports to find the best Technology stocks?
User
I want a SMA crossover strategy on TQQQ. I want a take profit strategy, but no stop losses — I’m bullish on tech long-term and don’t want to be stop lossed out. I also want to space out my buys and not go all-in at once.
User
Create a portfolio from this strategy with $10,000
Aurora
Description:
The SMA Crossover strategy for TQQQ is designed to capture momentum in tech stocks by using a crossover of the 20-day and 50-day Simple Moving Averages (SMA). This strategy aims to enter positions when the 20-day SMA crosses above the 50-day SMA, indicating a potential upward trend. Additionally, the strategy includes a take-profit mechanism to lock in gains when the price of TQQQ exceeds 1.1 times the 20-day SMA, ensuring that profits are realized without relying on stop losses. To manage risk and avoid going all-in at once, the strategy spaces out buys by ensuring at least one day has passed since the last buy order. This approach aligns with a bullish long-term outlook on tech stocks, allowing for gradual accumulation of positions while capturing upward momentum.
JSON:
User
Re-create this portfolio
Attachment: [{
"_id": "66e720e25eaefb549eeb3e51",
"userId": "63d96768efc1160d9c5e1482",
"name": "GPT-o1-mini TQQQ",
"deployment": {
"type": "paper-trading",
"frequency": "OpenClose"
},
"initialValue": 10000,
"buyingPower": 11.938485981884241,
"commissionPaid": 0,
"createdAt": "2024-09-15T18:01:06.602Z",
"main": false,
"active": true,
"positions": [
{
"asset": {
"name": "TQQQ",
"symbol": "TQQQ",
"type": "Stock"
},
"quantity": 135.94602306461238,
"lastPrice": 82.14,
"averageCost": 82.02094227573282
}
],
"strategies": [
{
"_id": "66e720e25eaefb549eeb3e47",
"name": "Buy 2500 dollars in TQQQ Stock when (50 Day TQQQ SMA > 200 Day TQQQ SMA) and (# of Days Since the Last Filled Buy Order of TQQQ ≥ 7)",
"userId": "63d96768efc1160d9c5e1482",
"condition": {
"name": "(50 Day TQQQ SMA > 200 Day TQQQ SMA) and (# of Days Since the Last Filled Buy Order of TQQQ ≥ 7)",
"_id": "66e720e2bd26b85b3c942f6e",
"comparison": null,
"conditions": [
{
"lhs": {
"targetAsset": {
"name": "TQQQ",
"type": "Stock",
"symbol": "TQQQ"
},
"window": {
"length": 50,
"interval": "Day"
},
"type": "SimpleMovingAverage",
"name": "50 Day TQQQ SMA"
},
"rhs": {
"targetAsset": {
"name": "TQQQ",
"type": "Stock",
"symbol": "TQQQ"
},
"window": {
"length": 200,
"interval": "Day"
},
"type": "SimpleMovingAverage",
"name": "200 Day TQQQ SMA"
},
"name": "(50 Day TQQQ SMA > 200 Day TQQQ SMA)",
"_id": "66e720e29f783a5ac614fa65",
"comparison": "greaterThan",
"type": "Base"
},
{
"lhs": {
"targetAssets": [
{
"name": "TQQQ",
"type": "Stock",
"symbol": "TQQQ"
}
],
"side": "Buy",
"type": "DaysSinceOrder",
"orderStatus": "Filled",
"name": "# of Days Since the Last Filled Buy Order of TQQQ"
},
"rhs": {
"value": 7,
"type": "Value",
"name": "7"
},
"name": "(# of Days Since the Last Filled Buy Order of TQQQ ≥ 7)",
"_id": "66e720e2524a30942226ade7",
"comparison": "greaterThanOrEqual",
"type": "Base"
}
],
"description": "All conditions must be true",
"example": "If asset is sold to open and the price is above the buy price, ...",
"type": "And"
},
"createdAt": "2024-09-15T18:01:06.602Z",
"action": {
"type": "Buy",
"targetAsset": {
"name": "TQQQ",
"type": "Stock",
"symbol": "TQQQ"
},
"amount": {
"amount": 2500,
"type": "dollars"
}
},
"automaticOrderApproval": false
},
{
"_id": "66e720e25eaefb549eeb3e49",
"name": "Sell 100 percent of current positions in TQQQ Stock when (14 Day TQQQ Rate of Change > 15)",
"userId": "63d96768efc1160d9c5e1482",
"condition": {
"name": "(14 Day TQQQ Rate of Change > 15)",
"_id": "66e720e2289481a403d28221",
"comparison": null,
"conditions": [
{
"lhs": {
"targetAsset": {
"name": "TQQQ",
"type": "Stock",
"symbol": "TQQQ"
},
"window": {
"length": 14,
"interval": "Day"
},
"type": "PriceRateOfChange",
"name": "14 Day TQQQ Rate of Change"
},
"rhs": {
"value": 15,
"type": "Value",
"name": "15"
},
"name": "(14 Day TQQQ Rate of Change > 15)",
"_id": "66e720e291b1bc1e0b0ccbe1",
"comparison": "greaterThan",
"type": "Base"
}
],
"description": "All conditions must be true",
"example": "If asset is sold to open and the price is above the buy price, ...",
"type": "And"
},
"createdAt": "2024-09-15T18:01:06.602Z",
"action": {
"type": "Sell",
"targetAsset": {
"name": "TQQQ",
"type": "Stock",
"symbol": "TQQQ"
},
"amount": {
"amount": 100,
"type": "percent of current positions"
}
},
"automaticOrderApproval": false
}
]
}]
Aurora
Description:
The portfolio "GPT-o1-mini TQQQ" is designed to capitalize on the momentum of the ProShares UltraPro QQQ (TQQQ) stock, which is a 3x leveraged ETF tracking the NASDAQ-100 Index. The strategy involves two main components:
- Buy Strategy: The portfolio will buy $2,500 worth of TQQQ when the 50-day Simple Moving Average (SMA) crosses above the 200-day SMA, indicating a potential bullish trend. Additionally, the strategy ensures that at least 7 days have passed since the last buy order to space out purchases and avoid going all-in at once. This approach helps in gradually accumulating positions and taking advantage of upward momentum.
- Sell Strategy: The portfolio will sell 100% of the current positions in TQQQ when the 14-day Price Rate of Change (ROC) exceeds 15%. This condition suggests a significant upward momentum, and selling at this point helps in locking in profits and managing risk.
The portfolio starts with an initial value of $10,000 and aims to leverage the volatility and potential gains offered by TQQQ while implementing risk management through spaced-out buys and a clear sell condition based on price momentum.
JSON:
User
Backtest both these portfolios for the past year. Compare them to TQQQ as the baseline
Aurora
JSON:
User
backtest both these portfolios for the past 5 years. Use TQQQ as the baseline
User
backtest these portfolios for the past 10 years
User
Refine, finalize strategy and provide Pine script code in version 6
Aurora
Below is a refined, finalized Pine Script strategy (version 6) that implements the two conditions found in the "GPT-o1-mini TQQQ" portfolio:
• A buy order is triggered when the 50‑day SMA is greater than the 200‑day SMA and at least 7 days have passed since the last filled buy (this is tracked using the bar index on the daily chart). In a real trading system you might need a more advanced mechanism to track order fills, but here we use bar count for simplicity.
• A sell order is triggered when the 14‑day rate of change (percentage) exceeds 15%.
Copy the code below into TradingView’s Pine Script editor (ensuring you’re on a daily timeframe) and adjust any parameters if needed.
//@version=6
strategy("GPT-o1-mini TQQQ Strategy", overlay=true, initial_capital=10000, currency=currency.USD, default_qty_type=strategy.fixed)
// Calculate SMAs
sma50 = ta.sma(close, 50)
sma200 = ta.sma(close, 200)
// Calculate 14-day Rate of Change (ROC) as a percentage
roc14 = ((close - close[14]) / close[14]) * 100
// Variable to store the bar index when the last buy was executed
var int lastBuyBar = na
// Define buy condition: SMA50 > SMA200 and at least 7 bars since the last buy
buyCondition = (sma50 > sma200) and (na(lastBuyBar) or (bar_index - lastBuyBar >= 7))
// Define sell condition: 14-day ROC exceeds 15%
sellCondition = roc14 > 15
// Execute buy: use a fixed dollar amount by converting dollars to contract quantity
if buyCondition
// Determine quantity to purchase based on $2500 dollars at current price
qty = 2500 / close
strategy.entry("Long", strategy.long, qty=qty)
// Reset lastBuyBar at the moment of a new buy entry
lastBuyBar := bar_index
// Execute sell: close the existing position when the sell condition is met
if sellCondition
strategy.close("Long")
// Plot SMAs for visual reference
plot(sma50, color=color.blue, title="50 Day SMA")
plot(sma200, color=color.red, title="200 Day SMA")
This Pine Script version 6 strategy replicates the refined conditions from the portfolio. You can further adjust the parameters or the quantity calculation as needed for your trading style.