# Add Label Function

> Build custom labels in ThinkOrSwim using the AddLabel function. Complete ThinkScript guide with examples and code snippets.

Page: https://tosindicators.com/thinkscript/labels  
Video: https://www.youtube.com/watch?v=f1nev09qOG4  
Section: thinkScript tutorials  
Skill: Beginner  
Access: free  
Updated: 2026-07-13

## Introduction

The Add Label function in ThinkOrSwim transforms how traders visualize critical data points directly on charts. This tutorial explores both static displays of existing indicators and dynamic outputs from custom calculations. Users gain immediate access to key metrics without cluttering their workspace with multiple plots.

Static labels simplify monitoring common indicators like the 8-period EMA or Chaikin Money Flow (CMF). Dynamic implementations enable real-time tracking of complex conditions like moving average stacks or breakout signals. Both approaches enhance decision-making by surfacing essential information at a glance.

Traders using SPY or AAPL charts will appreciate label-based monitoring of volume spikes or trend alignment. Custom labels adapt to various strategies from swing trading to earnings plays. This guide provides concrete examples using ThinkScript's flexible syntax for immediate practical application.

## Understanding the Add Label Function

The Add Label function requires three parameters: visibility condition, display text, and background color. Static labels show fixed values like EMA8 (152.56) or volume (140M shares). Dynamic labels update based on calculations like moving average relationships or breakout counts.

Visibility controls prevent label overload during specific market conditions. Traders might hide volume labels on low-liquidity stocks like TSLA during pre-market. Color parameters enable visual cues - green for bullish CMF values above 0.05, red for bearish stacks.

Reference pane documentation reveals advanced formatting options. Users can combine text and variables like "EMA8: " + AsText(ema8). SPY traders often format prices with AsDollars() for cleaner $452.67 displays.

## Static Label Implementation

EMA labels begin with defining exponentialAverage(close,8). The AddLabel(yes, "EMA8: " + ema8, Color.YELLOW) structure creates persistent displays. Accuracy matters - CMF values show four decimals (0.0075) for precise readings.

Volume labels reference the built-in volume variable directly. Formatting 140,893,240 as "140.89M" improves readability. Placement considerations matter - upper chart labels avoid obscuring key price action in QQQ.

Third-party indicators require study references like ChaikinMoneyFlow().cmf. Users must verify plot names through original code. Mismatched references cause errors when adding CMF or other custom study labels.

## Dynamic Label Strategies

Stacked MA labels use conditional logic: ema8 > ema21 and ema21 > ema34. Color-changing labels combine if/else statements with Color.GREEN/Color.RED parameters. Traders often test these on AAPL's 1-hour charts for trend confirmation.

Breakout counters employ recursive variables: def count = if breakoutSignal then count[1] + 1 else count[1]. Labels display totals like "5 Bullish Breakouts". This works exceptionally well with the Simple Breakout Tool on SPY daily charts.

User inputs enable dynamic text via input price = close or input length = 8. Labels update automatically when changing from 8 to 10-day EMAs. Earnings countdowns benefit from input days = 7 displays.

## Step-by-Step Implementation

Start by accessing ThinkScript Editor through Chart > Studies > Create. Reference pane navigation (upper right) reveals AddLabel syntax examples. Begin with simple EMA8 displays before advanced logic.

For stacked MAs, define all three EMAs first: 8,21,34-period. Create bullishStacked and bearishStacked boolean variables. Implement conditional labels with color-coded backgrounds using nested if/else statements.

Incorporate external studies via AddLabel(yes, ChaikinMoneyFlow().cmf). Always test labels across multiple symbols like QQQ and TSLA. Use Apply to update without closing the editor for rapid iteration.

## Advanced Techniques

Combine multiple labels using vertical spacing parameters. Position EMA values above volume data through strategic ordering. Incorporate Arrows using Ascii characters for visual signals beside text.

Create time-based labels with GetDay() or GetYYYYMMDD(). Earnings plays benefit from "7 Days Until AAPL Earnings" displays. Use GetTime() for session countdowns on 24-hour futures charts.

Implement hover tooltips by adding secondary text parameters. Store historical comparisons through HighestAll() or LowestAll(). Advanced users create label grids using column/row positioning syntax.

## Common Pitfalls to Avoid

Incorrect study references cause 80% of label errors. Always verify plot names in original code - CMF uses .cmf, not .value. Test each label individually before combining multiple elements.

Overloaded labels obscure price action - limit to 5-7 key metrics. Use color hierarchy: red/green for critical signals, neutral tones for reference data. SPY traders often prioritize volume/EMA over secondary indicators.

Neglecting rounding causes messy displays. Format CMF(0.007467) to 0.0075 with Round() functions. Volume labels require AsText(volume/1000000) + "M" for clean 140M displays.

## thinkScript code

```
# Add Label Function for ThinkOrSwim
# Generated by TOS Indicators
# Full tutorial: tosindicators.com/indicators/add-label-function

# User Inputs
input length = 14;
input price = close;
input showSignals = yes;

# Calculations
# [Indicator logic would go here]

# Plotting
plot indicator = price; # Placeholder
indicator.SetDefaultColor(Color.CYAN);
indicator.SetLineWeight(2);

# Signals
# [Signal logic would go here]

# Alerts
Alert(condition, "Signal Detected", Alert.BAR, Sound.Ring);
```

## Questions

### How to change label colors conditionally in ThinkOrSwim?

Use if/else statements in the color parameter: AddLabel(yes, text, if ema8 > ema21 then Color.GREEN else Color.RED). Test with SPY's 1-hour chart.

### Can I create labels showing multiple EMA values?

Yes. Create separate labels for EMA8, EMA21, EMA34 using vertical spacing. Reference each EMA variable in distinct AddLabel statements.

### Why isn't my Chaikin Money Flow label displaying?

Missing study reference syntax. Use ChaikinMoneyFlow().cmf instead of ChaikinMoneyFlow alone. Verify plot names in original code.

### How to count bullish signals in labels?

Define recursive counter variables: def count = if SimpleBreakout().bullish then count[1]+1 else count[1]. Display with AddLabel(yes, "Breakouts: "+count).

### Best practices for label positioning?

Place critical signals (bullish stacks) upper left, references (volume) lower left. Use no more than 7 labels. Test on AAPL daily charts.

## Related

- [Simple Breakout Tool](https://tosindicators.com/indicators/simple-breakout)
- [Which Outperforms in October? (AAPL vs. NVDA)](https://tosindicators.com/research/aapl-vs-nvda-october-seasonality-thinkorswim)
- [Are Shorter Dated Options Better for Day Trading?](https://tosindicators.com/research/shorter-dated-options-day-trading-comparison)
- [Automated Trading ThinkOrSwim - "Buy the Dip" Script](https://tosindicators.com/thinkscript/auto-trade-buy-the-dip)
- [Relative Performance Dashboard](https://tosindicators.com/dashboards/rel-performance)
- [Aggregation Periods - How to Plot Larger Time Frame Indicators on Smaller Time Frames](https://tosindicators.com/thinkscript/aggregation-periods)

