Building A Strategy With AI Strategy Lab | TrendSpider Blog Skip to Main Content

Building A Strategy With AI Strategy Lab

|
Share on social media

Trading is often a delicate balance between strategy and execution, and building the perfect system can feel like a daunting task. With so many factors to consider—data, timeframes, risk parameters—it’s easy to see why even experienced traders find it challenging. But what happens when you bring AI into the equation?

Building An AI Strategy With The AI Strategy Lab

For this case study, we used TrendSpider’s new AI Strategy Lab to tackle the task. The goal: to create an effective strategy for SPY, one of the market’s most closely watched indexes. From training the AI to refining the results, this deep dive reveals not just the process but the power of what’s possible with AI-driven strategy creation. Let’s see how it all came together.

Building An AI Strategy For SPY

Building an effective trading strategy starts with the foundation: a diverse data set, realistic goals, and the right set of tools. With the AI Strategy Lab, the process becomes a balance of leveraging machine learning and making smart choices to guide the model’s development. Here’s how each step was approached.

Choosing The Right Training Data

When building a strategy, the data you feed your model dictates how the model learns. For this case study, the one-hour timeframe on the SPY was selected, using data from December 1, 2018, to February 1, 2020.

This is an image that shows the market data the model was trained on.

This section of the chart was chosen for its varied market conditions, which included a sharp sell-off, a V-shaped recovery, a period of sideways consolidation and finally, a strong uptrend.

This image shows the chart of the market data the model was trained on.

Setting The Stage With Prediction Goals

The prediction goals were configured using the AI Strategy Lab’s preset settings: a 40-candle horizon, a 1.5% take profit (TP), and a 0.5% stop loss (SL). These settings represented a logical starting point, balancing a reward-to-risk ratio of 3:1 with SPY’s typical price movements over a seven-day period. The goal was to test the AI’s ability to uncover patterns and opportunities within these boundaries.

This image shows the prediction chart.

Starting With A Simple Model

To keep things straightforward, the Logistic Regression (LR) model was selected as the starting point. This model is an excellent choice for building a foundational understanding of the data before exploring more advanced models.

This image shows the model type used for this model.

Crafting An RSI-Based Model

For the model inputs, the AI Strategy Lab’s built-in RSI prompt provided a strong starting point. However, after the initial models showed limited success, the input parameters were manually adjusted to longer RSI lengths: 14, 20, 28, and 56. These lengths were selected to approximate the concept of multi-time frame analysis, an approach which allowed the AI to analyze interactions across different time horizons while maintaining a straightforward and focused setup.

This image shows the model inputs.

Training The Model

With the training data and inputs defined, the AI Strategy Lab began training the Logistic Regression model. While the results were not deployment-ready, they offered a glimpse of potential. The confidence vs. win rate chart hinted at opportunities worth exploring, prompting the use of the ‘Try Other Model Types’ feature to test the same inputs with alternative models. That’s when things got interesting.

This is an image of the Linear Regression model.

The Naive Bayes model produced similar results as the Logistic Regression model, but the K-Nearest Neighbors (KNN) and Random Forest (RF) models both showed significant promise. Their confidence vs. win rate charts were distinctly ‘up and to the right’, suggesting that higher confidence predictions correlated strongly with higher win rates.

This is an image of all four models.

Encouraged by these results, both models were deployed for further testing under the labels ‘RSI Model 1 (KNN)’ and ‘RSI Model 2 (RF)’. By deploying a model, it can be utilized across TrendSpider; In the Strategy Tester and Strategy Variance Explorer, as well as on-chart, in alerts, scans, and Trading Bots. More on that later.

This is an image of the deployed models.

Backtesting The Models

The first step in validating an AI strategy is to test it on out-of-sample data. Since the models were trained on data from December 1st, 2018 to February 1st, 2020, an alternative data set was selected for the strategy test; Specifically, the period from February 1st, 2020, onward. Here’s how the results compared:

RSI Model 1 (KNN) delivered an 18.7% return, compared to SPY’s 84.7% over the same period. While the return was modest, its 3.02 reward-to-risk ratio and -6.5% max drawdown showed excellent risk management.

This is an image of the KNN model backtest.

RSI Model 2 (RF) outperformed, with a 53.5% total return, a 2.82 reward-to-risk ratio, and a -9.7% max drawdown. This model also had a higher trade frequency and win rate.

This is an image of the RF model backtest.

While Model 1 demonstrated stronger risk management, Model 2 provided better overall returns, making it the preferred choice for further refinement.

Refining The Strategy: Optimizing Exits

It’s not possible to modify the entry conditions determined by the AI, so refinements focused on exit parameters. Notably, when observing the charts, it was clear that there was a chance to capture more of the trend while maintaining reasonable risk levels.

This is an image of the chart that shows exits that could be optimized.

To address this, the exit conditions were adjusted in these ways:

  • Take Profit: Increased from 1.5% to 5%.
  • Stop Loss: Widened from 0.5% to 2%.
  • Horizon: Shortened from 40 candles to 35.
This image shows the exit conditions of the model's strategy test.

These adjustments transformed the strategy, delivering a 119.4% return, outperforming SPY’s buy-and-hold by 34.7%. The win rate improved to 55%, and the max drawdown remained manageable at -18.8%, compared to SPY’s -35.1% over the same period. This new iteration of the strategy delivered market-beating returns with half the risk.

This is an image of the backtest of the adjusted exit strategy.

Expanding Horizons: Testing Variants with Strategy Variance Explorer

The next step was to evaluate how the strategy performed across different timeframes and assets using the Strategy Variance Explorer. While initially developed for SPY, variance testing allows for exploring the possibility that a strategy may perform even better when applied in new ways.

Testing included a range of new timeframes, such as 5m, 10m, 15m, 30m, 65m, 90m, 2h, and 4h. On the asset side, the focus remained on major indexes, specifically QQQ and IWM, to complement the original SPY analysis.

This is an image of the variance test which shows that QQQ was the best option for this strategy.

The results were eye-opening. The best-performing combinations didn’t come from SPY but instead from QQQ, with the 90m, 2h, and 4h timeframes showing the most promising performance. Among these, the 90m timeframe stood out as the clear leader.

Here’s why: the 90m strategy delivered a 256.4% total return, outperforming the buy-and-hold approach over the same period by nearly 90%. It also boasted the highest win rate of the three time frames at 52%, alongside the largest average return per trade at 0.82%.

This is a zoomed in image of the 3 time frames on the QQQ that work the best.

Beyond returns, the strategy proved adept at managing risk, with a max drawdown of -18.3%, significantly better than the -37.3% drawdown of buy-and-hold. This combination of high returns, consistent performance, and reduced risk made the 90m QQQ strategy an unexpected, yet exceptionally compelling outcome.

Putting the Strategy Into Action

With the best-performing asset and timeframe identified, the strategy can be deployed in a number of ways across TrendSpider.

On-Chart Visualization and Alerts

Accessed via the ‘manage indicators’ toolbox, deployed strategies can appear as text labels, allowing for visualizing new signals as they arrive. To receive a notification each time a signal emerges, AI model conditions like ‘Signal Emerged’ can be selected as a parameter in a multi-factor alert.

This image shows the model signals painted on the chart.

Forward Testing with Trading Bots

Before taking any new trading strategy live, forward testing is a crucial step to ensure its real-world effectiveness. Unlike backtesting, which evaluates performance on historical data, forward testing simulates real-time market conditions to validate whether a strategy can consistently perform as expected.

With TrendSpider’s Trading Bots, forward testing becomes seamless—allowing us to deploy our model strategy in live market conditions with simulated or real accounts, ensuring confidence before committing capital.

This image shows the model being deployed in a trading bot.

Redefining Strategy Building With AI Strategy Lab

The AI Strategy Lab has proven to be a game-changer in the process of strategy creation. From selecting training data to refining exit parameters and testing variants across multiple assets and timeframes, this tool empowers traders to uncover actionable strategies that might otherwise remain hidden.

In this case study, a simple RSI-based model evolved into a high-performing strategy, delivering market-beating returns with reduced risk. The ability to adapt the strategy to new assets like QQQ and discover optimal timeframes such as the 90-minute chart highlights the versatility of AI-driven trading.

With deployment options like on-chart visualization, real-time alerts, and forward testing via trading bots, TrendSpider ensures that traders can confidently put their strategies into action. Whether you’re optimizing a single indicator or experimenting with multiple variants, the AI Strategy Lab opens a world of possibilities for traders looking to take their edge to the next level.

 

 

Stay up-to-date: Subscribe to posts like this!

Receive automated updates from the Case Studies category
This site is protected by reCAPTCHA and the Google Privacy Policy and Google Terms of Service apply. Don't worry, we hate spam, too! See TrendSpider Privacy Policy for details.

Latest posts

|

Market Update Into September 7th: Inflation Data Incoming

Markets whipsawed last week as a wave of strong AI earnings hit the tape, crypto caught a bid, and Friday’s jobs report came in far hotter than expected, with 162,000 jobs added against estimates of just 53,000. AI and memory names led the charge as $AVGO, $DELL, and $HPE all crushed earnings, with $SNDK and […]
|

Uber Stock Faces AV Reckoning as Tesla Cybercab Launches

Uber Technologies (UBER) stock kicked off September with a double blow: a 3,300-person layoff (roughly 10% of its workforce) announced on September 2 to flatten management layers, immediately followed by the launch of Tesla’s Cybercab robotaxi service in Austin on September 4. Shares sold off heading into the Tesla event but have stabilized near $75-$76, […]
|

LULU Stock Tumbles After Q2 Earnings

Lululemon Athletica (LULU) stock reported Q2 2026 earnings of $2.92 per share, beating the $1.80 estimate by over 62%, but the headline beat was heavily distorted by an $0.86 EPS contribution from one-time IIPA tariff refunds. Revenue of $2.416B missed the $2.458B estimate, and the company slashed full-year 2026 EPS guidance from $10.95-$11.15 down to […]
|

DELL Stock Soars 15% on Q2 Beat, FY27 Guidance Boost

Dell Technologies (DELL) stock exploded higher after reporting Q2 FY2027 results on September 1 that crushed every major estimate: revenue of $47B (+58% YoY) versus the $45B consensus, and adjusted EPS of $7.04 versus the $4.91 estimate, a 43% beat. The company simultaneously raised its full-year revenue guidance from a $165B-$169B range to $192B and […]