Better Moving Average Labels for Thinkorswim

Moving Average Labels for Thinkorswim

Moving averages are probably one of the most popular technical trading indicators. Why? Because so many traders respect them – especially longer such averages like the 200 day. They are commonly used to identify trends in stock price movement and mark support and resistance levels. Thinkorswim makes it very easy to add these indicators to your charts. But the default moving average indicators that come with the platform may not perform as you expect. Follow the video below and let Steve with FloatChecker explain how you can improve on these studies with easy-to-read labels. You can also scroll down to the bottom to get the related thinkscript code.


  • What are Moving Averages?
  • How are Moving Averages used?
  • Limitations
  • Adding Moving Averages in Thinkorswim
  • Limitations of the Default Moving Averages
  • Moving Average Chart Labels
  • Conclusion

What are Moving Averages?

As the name indicates, a moving average (MA) is determined by taking the sum of a stock’s closing price over a given time period and then dividing the sum by the time period to get an average. That number updates as you move forward in time and can be plotted as a line on a stock chart (hence the term moving average). Popular indicators include the 50-day and 200-day moving average, but any time frame can be chosen.

The moving average line represents a smoothing of a stock’s price. In this way, price fluctuations are minimized so you can see the direction of the trend. Two common types include the simple moving average and the exponential moving average. The main difference between the two is the lag time between a stock’s price and the trend in the moving average line.

A simple moving average (SMA) gives equal weight to each price in the time frame. So, for a 20-day moving average, the price on day 1 is weighted equally as the price on day 20. In contrast, an exponential moving average (EMA) gives greater weight to the most recent prices. A perceived benefit is that the EMA will react more quickly to price changes than the SMA. But the faster reaction could result in providing false or incorrect trading signals too early. As a result, it is difficult to say whether one is better than the other. The figure below shows the difference in lag time between a 50-day SMA vs. a 50-day EMA for the stock of Tesla, Inc.

Tesla Moving Average Lag Time
Stock Chart of TSLA showing Lag Time Difference of 50-day EMA vs. 50-day SMA

How are Moving Averages used?

As previously stated, a primary benefit of the moving average indicator is to get a sense of whether a stock’s price is trending to the upside or to the downside. When the price crosses above the MA, that may signal a bullish or upward trend. Conversely when the price crosses below the MA, that may signal a bearish or downward trend.

It is also common for traders to use a combination of MA indicators to look for buy and sell signals. For example, a potential upward price move, known as a “golden cross,” occurs when a shorter-term MA crosses above a longer-term MA. A potential down trend, or “death cross,” occurs when the shorter-term MA breaks below the longer-term MA.

While there is a myriad of ways to work with moving averages, one simple method is to identify support and resistance levels. As a stock price moves down toward the MA and then bounces back up, that may indicate the start of a trend to the upside. And as a stock moves up toward the MA and then fails to cross, that may signal a trend back to the downside. Longer time frames such as the 200-day MA and the 50-day MA are widely followed by traders and are considered significant areas of support and resistance. In the figure below, the stock for Applied DNA Sciences, Inc. had a big move in the morning and quickly reversed near its 200-day MA. Traders watching that level would have had a strong signal to sell near the top of the move.

Stock Chart of APDN Touching 200-Day Moving Average
One Minute Stock Chart of APDN hitting 200-Day SMA on August 2, 2022


Moving averages are considered backward-looking indicators because they only rely on past stock prices. As a result, an argument can be made they are ineffective at predicting future price movement. Moving averages also don’t account for underlying stock fundamentals or larger market trends and cycles. They may also show conflicting trends depending on the duration viewed. For example, a 20-day moving average might suggest an upward direction in price, but the longer 200-day moving average might indicate a larger overall move downward. In those situations, it can be difficult to determine which time periods to trust. That’s one reason why so many traders rely on a combination of different technical indicators to better help them confirm price movement.

Adding Moving Averages in Thinkorswim

From your trading chart, you can add a MA indicator by clicking on the “Edit Studies and Strategies” icon, which looks like a beaker. Then start typing “simple” or “exponential” in the search bar and you’ll be given the option to add either to your chart. You can also add multiple MA studies on the same chart. Once added, you can click the gear icon to adjust the settings. You can edit the length to your preferred time period and change the color to better distinguish between different MA lines. Follow along with our video if you need additional help.

Limitations of the Default Moving Averages

The preset, default moving average studies for Thinkorswim are tied to the time frame you choose on you chart. For example, if you set a SMA to a length of 9 and your chart is set to 1-minute candles, the SMA line will be based on the last 9-minute candles. If you change your time frame to one day, then the SMA line will change and be based on the last 9 daily candles or bars. In this way, the moving average can seem to vary based on your time frame.

Ordinarily, the differing MA lines may not be a problem if you consistently use the same time period. But it could cause confusion if you set your MA to 50 or 200 thinking it represents only the 50-day or 200-day MA. While that may be accurate on the daily chart, you will see how the MA line changes when you adjust your time frame. That may be problematic if you are trying to watch these higher time periods when trading on smaller time charts. Fortunately, we can use the built-in programming language thinkscript to make labels set to specific time frames so that the values are constant regardless of the time of your chart.

Moving Average Chart Labels

The code below has labels you can use for different daily time frames. They include simple moving averages and exponential moving averages. The duration lengths are merely suggestive and can be tailored to your needs. You can also adjust the colors if you have some basic knowledge of RGB color coding. You may also decide you don’t need every label. In that case, you can delete or comment out the sections you don’t want. Watch our short video if you need help with installing the script.

#General Inputs
input price = FundamentalType.CLOSE; #use closing price
input aggregationPeriod = AggregationPeriod.DAY; #use daily time period

#Start Simple Moving Average Labels
input averageType = AverageType.SIMPLE;

#20 day simple moving average
input length20 = 20;
DefineGlobalColor("SMA20",  CreateColor(149, 212, 122)) ;
def MovAvg20 = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod), length20);
AddLabel( yes, "SMA(20) " + Round(MovAvg20), GlobalColor("SMA20"));

#50 day simple moving average
input length50 = 50;
DefineGlobalColor("SMA50",  CreateColor(92, 204, 206)) ;
def MovAvg50 = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod), length50);
AddLabel( yes, "SMA(50) " + Round(MovAvg50), GlobalColor("SMA50"));

input length200 = 200;
DefineGlobalColor("SMA200",  CreateColor(160, 158, 214)) ;
def MovAvg200 = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod), length200);
AddLabel( yes, "SMA(200) " + Round(MovAvg200), GlobalColor("SMA200"));

#Start Exponential Moving Average Labels
input averageTypeEXP = AverageType.EXPONENTIAL;

#20 day exponential moving average
input length20exp = 20;
DefineGlobalColor("EMA20",  CreateColor(246, 143, 160)) ;
def MovAvg20exp = MovingAverage(averageTypeEXP, Fundamental(price, period = aggregationPeriod), length20exp);
AddLabel( yes, "EMA(20) " + Round(MovAvg20exp), GlobalColor("EMA20"));

#50 day exponential moving average
input length50exp = 50;
DefineGlobalColor("EMA50",  CreateColor(250, 198, 14)) ;
def MovAvg50exp = MovingAverage(averageTypeEXP, Fundamental(price, period = aggregationPeriod), length50exp);
AddLabel( yes, "EMA(50) " + Round(MovAvg50exp), GlobalColor("EMA50"));

#200 day exponential moving average
input length200exp = 200;
DefineGlobalColor("EMA200",  CreateColor(250, 122, 255)) ;
def MovAvg200exp = MovingAverage(averageTypeEXP, Fundamental(price, period = aggregationPeriod), length200exp);
AddLabel( yes, "EMA(200) " + Round(MovAvg200exp), GlobalColor("EMA200"));


Incorporating moving averages into your trading is simple. Unfortunately, the standard MA indicators that come with Thinkorswim may be more difficult to understand than you think. Hopefully these labels will go a long way to help you better see important price levels and improve your trading.