SMA vs. Tesla Chaos: Backtesting Through the Hype

In partnership with

TV Ads That Perform Like Digital

We have entered a new era of TV advertising where the barriers to entry are lower than ever, and Roku Ads Manager is leading the way.

Growth marketers can access Roku’s audience reach in the US with a self-service ad platform that’s built for performance.

Roku powers 47% of all TV streaming time in the US*, so your brand can run ads alongside premium content and meet your audience where they’re already engaged. *Comscore, 2024

🚀 Your Investing Journey Just Got Better: Premium Subscriptions Are Here! 🚀

It’s been 4 months since we launched our premium subscription plans at GuruFinance Insights, and the results have been phenomenal! Now, we’re making it even better for you to take your investing game to the next level. Whether you’re just starting out or you’re a seasoned trader, our updated plans are designed to give you the tools, insights, and support you need to succeed.

Here’s what you’ll get as a premium member:

  • Exclusive Trading Strategies: Unlock proven methods to maximize your returns.

  • In-Depth Research Analysis: Stay ahead with insights from the latest market trends.

  • Ad-Free Experience: Focus on what matters most—your investments.

  • Monthly AMA Sessions: Get your questions answered by top industry experts.

  • Coding Tutorials: Learn how to automate your trading strategies like a pro.

  • Masterclasses & One-on-One Consultations: Elevate your skills with personalized guidance.

Our three tailored plans—Starter Investor, Pro Trader, and Elite Investor—are designed to fit your unique needs and goals. Whether you’re looking for foundational tools or advanced strategies, we’ve got you covered.

Don’t wait any longer to transform your investment strategy. The last 4 months have shown just how powerful these tools can be—now it’s your turn to experience the difference.

With Tesla stock swinging wildly after Trump’s latest jabs at Elon Musk, I couldn’t help but wonder.

Would a simple moving average (SMA) strategy survive this kind of hype-fueled volatility?

So I ran a simple backtest using TSLA’s daily prices from the past year. No machine learning, no fancy modeling — just a classical SMA crossover strategy.

This isn’t about predicting the market or proving anything definitive. It’s about seeing how a plain old rule behaves when the noise gets loud.

Your boss will think you’re a genius

Optimizing for growth? Go-to-Millions is Ari Murray’s ecommerce newsletter packed with proven tactics, creative that converts, and real operator insights—from product strategy to paid media. No mushy strategy. Just what’s working. Subscribe free for weekly ideas that drive revenue.

Wrapping the SMA Strategy into a Simple Function

Rather than rewriting the same logic over and over, I wrapped the SMA strategy I wrote in the previous article into a function. This also makes it easier to experiment with things like window size and stock tickers.

import yfinance as yf
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

def sma_strategy(df_org,window,draw = True):
    df = df_org.copy()
    df['SMA'] = df.rolling(window=window).mean().fillna(0)
    df['Signal'] = (df[brand] < df['SMA']).astype(int)
    df['Position'] = df['Signal'].diff()
    df['Buy'] = (df['Position'] == 1).astype(int)
    df['Sell'] = (df['Position'] == -1).astype(int)
    
    # If there is a final unmatched Buy, we force-close it at the last available price
    if (df['Buy'] - df['Sell'] ).sum() > 0:
        df['Sell'].iat[-1] = 1
    
    df['Profit'] = (df['Sell']*df[brand] - df['Buy']*df[brand]).cumsum()
    df['Profit on sale'] = (df['Profit']*df['Sell']).cumsum()

    if draw is True:
        fig,axs = plt.subplots(2,1,figsize=(14,8))
        ax = axs[0]
        ax.plot(df.index,df[brand],label = brand ,color='black')
        ax.plot(df.index[window:],df['SMA'][window:],label = 'SMA' ,color='grey')
        ax.scatter(df.index,(df['Buy']*df[brand]).replace(0,np.nan),label='Buy',color='blue')
        ax.scatter(df.index,(df['Sell']*df[brand]).replace(0,np.nan),label='Sell',color='red')
        ax.label_outer()
        ax.set_title('SMA Crossover Strategy: '+str(brand))
        ax.set_ylabel('Price')
        ax.grid()
        
        ax = axs[1]
        ax.plot(df.index,df['Profit on sale'])
        ax.set_ylabel('Pofit')
        ax.set_xlabel('Date')
        ax.grid()
    
    return df

Here’s how I used the function to test SMA on Tesla (TSLA) over the past year.

brand = 'TSLA'
df_org = yf.download(brand, start="2024-04-01", end="2025-06-07")['Close']
sma_strategy(df_org,20)

Here’s the cumulative profit using a simple 20-day SMA on TSLA. I wasn’t expecting much from such a basic rule, but it actually ended up in the green.

Cumulative profit based on sell signals from a 20-day SMA. Not flashy, but steady.

Exploring Different SMA windows

After seeing that the 20-day SMA surprisingly produced a positive result, I wanted to see how the strategy would perform across a range of window sizes.

The following loop runs the same logic for window size from 2 to 50, and collects the final cumulative profit from each run.

dfs = []
for window in range(2,51):
    df = sma_strategy(df_org,window,False)
    dfs.append(df['Profit on sale'].to_frame(name=window))
result = pd.concat(dfs,axis=1)

result.iloc[-1,:].plot(xlabel='Window size',ylabel='Final profit on sale', title = 'SMA Crossover Strategy: '+str(brand), grid = True)

Final profit on sale across different SMA window sizes.

Turns out, the choice of window size makes a huge difference. Some windows barely stay profitable — others amplify the trend just enough to catch solid gains.

A Closer Look at Window size = 2

Among all the window size I tested, the 2-day SMA turned out to be the most profitable — by a large margin. To dig deeper, I plotted the buy/sell points along with the cumulative profit timeline. Let’s see how this ultra-short-term strategy behaved over time.

brand = 'TSLA'
df_org = yf.download(brand, start="2024-04-01", end="2025-06-07")['Close']
sma_strategy(df_org,2)

2-day SMA strategy on TSLA: fast trades, fast gains — but is it sustainable?

Can You Strategize Around Chaos?

The 2-day SMA looks like a winner — for now. But when stock movements hinge on late-night tweets and unpredictable emotions, maybe “strategy” is just a comforting myth.

In markets ruled by chaos, not planning might be the ultimate plan.