Technical Equations

Explore the mathematical foundations of trading indicators.

Simple Moving Average (SMA)

The Formula
What it shows: The SMA smooths out price data to help identify trends. Traders commonly use three SMAs together: 50-day (short-term), 100-day (medium-term), and 200-day (long-term). When price is above the SMA, it suggests an uptrend; below suggests a downtrend. When a shorter SMA crosses above a longer one, it's a bullish signal.

The Simple Moving Average is calculated as:

$$ SMA = \frac{1}{n} \sum_{i=1}^{n} P_i $$

Where \( P_i \) is the price at period \( i \), and \( n \) is the number of periods.

Example with Real Numbers

Let's calculate a 5-day SMA:

Stock prices over 5 days:

  • Day 1: $10
  • Day 2: $12
  • Day 3: $11
  • Day 4: $13
  • Day 5: $14

Step 1: Add all the prices together
$10 + $12 + $11 + $13 + $14 = $60

Step 2: Divide by the number of days (5)
$60 ÷ 5 = $12

Answer: The 5-day SMA is $12

Relative Strength Index (RSI)

The Formula
What it shows: The RSI (Relative Strength Index) measures momentum on a scale of 0-100 to identify overbought or oversold conditions. Above 70 suggests the asset is overbought (potentially due for a pullback). Below 30 suggests it's oversold (potentially due for a bounce). The standard period is 14 days. RSI helps traders identify potential reversal points.

The RSI is calculated as:

$$ RSI = 100 - \frac{100}{1 + RS} $$

Where \( RS = \frac{\text{Average Gain}}{\text{Average Loss}} \) over \( n \) periods (typically 14).

Example with Real Numbers

Simplified 5-day RSI example:

Price changes over 5 days:

  • Day 1: +$2 gain
  • Day 2: +$3 gain
  • Day 3: -$1 loss
  • Day 4: +$1 gain
  • Day 5: -$2 loss

Step 1: Calculate average gain
($2 + $3 + $1) ÷ 5 = $1.20

Step 2: Calculate average loss
($1 + $2) ÷ 5 = $0.60

Step 3: Calculate RS
$1.20 ÷ $0.60 = 2.0

Step 4: Calculate RSI
100 - (100 ÷ (1 + 2.0)) = 100 - 33.33 = 66.67

Answer: The RSI is 66.67 (above 50 suggests bullish momentum)

Average True Range (ATR)

The Formula
What it shows: The ATR (Average True Range) measures market volatility by calculating the average range of price movement. Higher ATR means bigger price swings and more volatility. Lower ATR means calmer, more stable prices. Traders use ATR to set stop-loss levels (e.g., 2x ATR from entry price) and adjust position sizes—riskier to trade during high ATR. The standard period is 14 days.

The ATR is calculated as:

$$ ATR = \frac{1}{n} \sum_{i=1}^{n} TR_i $$

Where \( TR_i = \max(H_i - L_i, |H_i - C_{i-1}|, |L_i - C_{i-1}|) \), with \( H_i \), \( L_i \), and \( C_{i-1} \) being the high, low, and previous close prices.

Example with Real Numbers

Calculate a 3-day ATR:

Day 1: High=$15, Low=$12, Previous Close=$13

Find the biggest of these three:
• High - Low = $15 - $12 = $3 ✓ Biggest!
• High - Prev Close = $15 - $13 = $2
• Prev Close - Low = $13 - $12 = $1
Day 1 True Range = $3

Day 2: High=$17, Low=$14, Previous Close=$15
True Range = $3

Day 3: High=$16, Low=$13, Previous Close=$16
True Range = $3

Final Step: Average the 3 True Ranges
($3 + $3 + $3) ÷ 3 = $3

Answer: The 3-day ATR is $3 (higher ATR = more volatility)