In my initial post on finding a trading strategy with edge using ChatGPT, I showed how I quickly came up with a strategy idea and was able to improve it using carefully chosen prompts. First, ChatGPT suggested a very generic trading strategy based on a simple moving average crossover. I asked for something more unique and it recommended a strategy based on extreme values of RSI and Bollinger Bands. In this post, I’ll demonstrate how I took this basic trading idea and found more trading edge using the advice given by ChatGPT.
I left off at the point where ChatGPT made several suggestions about improving the trading strategy. Here are the recommendations:
ChatGPT: It’s essential to fine-tune your trading strategy to achieve better profitability. Here are some filters you can consider adding to the Bollinger Band/RSI system to increase the likelihood of more profitable trades:
- Trend confirmation: Add a moving average or another trend-following indicator to confirm the overall trend direction. For example, you can use a 200-day simple moving average (SMA). Only take long trades when the price is above the 200-day SMA (uptrend) and short trades when the price is below the 200-day SMA (downtrend).
- RSI level adjustment: Adjust the RSI overbought and oversold levels to increase the selectivity of your entry signals. For example, you can use 80 and 20 instead of 70 and 30. This way, you’ll only enter trades when the market is more extremely overbought or oversold.
- Bollinger Band width filter: To avoid trading in sideways or consolidating markets, you can add a filter based on the width of the Bollinger Bands. Calculate the Bollinger Bandwidth as the difference between the upper and lower bands divided by the middle band (20-day SMA). Only take trades when the Bollinger Bandwidth is above a certain threshold, indicating higher volatility and stronger trends.
- Volume confirmation: Add a volume filter to confirm the strength of the price movements. For example, only take trades when the volume is above the 50-day moving average of volume. This helps to filter out potential false breakouts or weak price movements.
- Time of day filter: Limit your trading to specific hours of the day when the market tends to be more active and have higher liquidity. For example, you can focus on the first two hours after the market opens and the last two hours before the market closes, as these periods often experience higher volatility.
- Support and resistance levels: Incorporate support and resistance levels into your trading strategy. Look for price action near key support and resistance levels, as they can act as a confirmation for the Bollinger Band/RSI signals. For instance, a bounce off a support level combined with an oversold RSI signal could strengthen the case for a long trade.
Trend Confirmation Filter
Trends, of course, can mean different things to different traders. My goal here is to come up with a strategy as quickly as possible, so I chose a filter that would be quick to implement and test. The filter is ATRs away from the 200 period moving average. So in pseudocode:
(Entry - MA200) / ATR
Where MA200 = 200 period moving average and ATR = average true range. Why use average true range and not just distance? Imagine a high priced stock like $META (currently $239) versus a low priced stock like, say $PTON (currently $9.26). A $1 move in $PTON is going to be a lot more dramatic than a $1 move in $META. Using ATR like this normalizes that movement. When I looked at this filter, I found that the further away the price was from the moving average, the more reliable the signal seemed to be:
And remember, the dark line is lower, but it has a lot fewer trades so the strategy is significantly improved. In general, I’m looking for a smoother equity curve and more efficiency so although the dark green curve is lower, it’s FAR better than the top one because it has almost the same amount of profit with just a third of the trades.
Time Of Day Filter
Another suggestion from ChatGPT was to look at the time of day that the signal occurred. I know from experience that this is typically a good suggestion. Entries too late in the day won’t give the trade enough time to play out before the close and I suspect that entries too close to the open could easily turn out to be false positives.
Sure enough, it looks like skipping the first bar of the day makes sense as predicted by ChatGPT – notice the dark green curve continuing to smooth out:
RSI Level Adjustment
ChatGPT suggested looking at the RSI (Relative Strength Index) level for the signal. Let’s see if a more extreme level makes sense. Again, at first glance, it doesn’t seem that different but it’s almost the same profit with only 25% of the trades. The quality of the equity curve is getting better and better.
Support and Resistance Levels
Like “trend”, support and resistance are often in the eye of the beholder. It would be impossible to identify exact, custom support and resistance levels for each of the hundreds of trades remaining in this backtest.
I want to be completely automated, so what I would normally do at this point is to start reviewing a lot of charts to try to detect a pattern of general support and resistance that could be tested across all the trades. That won’t work for the purposes of this experiment – I’m trying to come up with a profitable strategy using ChatGPT as quickly as I can.
To capture a lot of what ChatGPT is suggesting here with as little time as possible, I decided to look at the range of the previous day. For example, if the entry is below yesterday’s low then it might be beyond any support. If it’s near or in yesterday’s range, it could be more likely that it’s running into support which would make it more likely to revert to the mean. To quickly see this in aggregate across a backtest, I created a new data point in each trade to examine. I’m calling this Position in Yesterday’s Range:
(Entry - Yesterday's Low) / (Yesterday's High - Yesterday's Low) * 100
A value of 100 means it’s right at Yesterday’s High. A value of 0 means it’s right at Yesterday’s Low. A value of -100 means it’s below Yesterday’s Low by an amount exactly equal to Yesterday’s Range (Yesterday’s High – Yesterday’s Low).
It turns out there is a threshold that makes sense. The entry price needs to be beyond the low from yesterday, but not by an excessive amount.
The equity curve is smoother still – more trades without sacrificing that much overall profit. It’s starting to look like something that might be worth trading.
This is a lot of progress in a short amount of time thanks to ChatGPT. What would the next steps be for me? There are two things that stick out in my mind right now.
First, I’ve only looked at the filters that ChatGPT suggested – I haven’t even looked at the list of indicators that I examine for each strategy I trade. While I don’t end up applying every one of those indicators in my list to the final model, I definitely analyze the effect on each of my strategies.
Second, if you look at the equity curve closely, you’ll see an odd looking inflection point:
I’ll want to examine the trades around that time and see if there’s something weird going on there. It could be nothing but it could also point to a data issue or some outliers that are worth understanding more deeply.
Thanks for the write up Dave, very educational!