Trend Indicators
Trend indicators help identify the direction and strength of market trends, enabling traders to follow momentum and avoid counter-trend trades.
Moving Average Convergence Divergence (MACD)
Calculation
MACD shows the relationship between two moving averages of price, revealing changes in trend strength, direction, and momentum.
Formula:
MACD Line = EMA(12) - EMA(26)
Signal Line = EMA(9) of MACD Line
Histogram = MACD Line - Signal Line
Standard Settings: 12, 26, 9
Step-by-Step Example:
Day 1-26: Calculate EMA(12) and EMA(26)
EMA(12) = 105.50
EMA(26) = 104.20
MACD Line = 105.50 - 104.20 = 1.30
Day 27-35: Calculate Signal Line
Signal Line = EMA(9) of MACD values
Signal Line = 1.15
Histogram = 1.30 - 1.15 = 0.15
Components
| Component | Calculation | Purpose |
|---|---|---|
| MACD Line | Fast EMA - Slow EMA | Shows momentum direction |
| Signal Line | 9 EMA of MACD | Triggers buy/sell signals |
| Histogram | MACD - Signal | Shows momentum strength |
Characteristics
- Range: Unbounded (oscillates around zero)
- Bullish: MACD > 0 and rising
- Bearish: MACD < 0 and falling
- Standard Settings: 12, 26, 9
- Fast Settings: 8, 17, 9 (for shorter timeframes)
Interpretation
| Signal | Condition | Meaning |
|---|---|---|
| Bullish Crossover | MACD crosses above Signal | Buy signal |
| Bearish Crossover | MACD crosses below Signal | Sell signal |
| Zero Line Cross | MACD crosses above/below 0 | Trend change |
| Histogram Expansion | Histogram growing | Momentum increasing |
| Histogram Contraction | Histogram shrinking | Momentum decreasing |
Usage Examples
MACD Bullish Crossover:
{
"indicator1": "macd",
"period1": "12,26,9",
"indicator2": "macd_signal",
"period2": "12,26,9",
"comparison": "crosses_above"
}
// MACD line crosses above signal line = buy
MACD Zero Line Cross:
{
"type": "indicator_value",
"indicator": "macd",
"period": "12,26,9",
"comparison": "crosses_above",
"value": 0
}
// MACD crosses above zero = bullish trend
Histogram Turns Positive:
{
"type": "indicator_value",
"indicator": "macd_histogram",
"period": "12,26,9",
"comparison": "crosses_above",
"value": 0
}
// Histogram crosses above zero = momentum shift
MACD Strategies
1. Classic MACD Crossover:
{
"entryConditions": {
"long": {
"conditions": [
{
"indicator1": "macd",
"period1": "12,26,9",
"indicator2": "macd_signal",
"period2": "12,26,9",
"comparison": "crosses_above"
}
]
},
"short": {
"conditions": [
{
"indicator1": "macd",
"period1": "12,26,9",
"indicator2": "macd_signal",
"period2": "12,26,9",
"comparison": "crosses_below"
}
]
}
}
}
2. MACD with Trend Filter:
{
"entryConditions": {
"long": {
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"price": "close",
"indicator": "ema",
"period": 200,
"comparison": "above"
},
{
"indicator1": "macd",
"period1": "12,26,9",
"indicator2": "macd_signal",
"period2": "12,26,9",
"comparison": "crosses_above"
}
]
}
}
}
// Only take MACD signals in uptrend (above 200 EMA)
3. MACD Histogram Reversal:
{
"entryConditions": {
"long": {
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "macd_histogram",
"period": "12,26,9",
"comparison": "below",
"value": 0
},
{
"type": "indicator_value",
"indicator": "macd_histogram",
"period": "12,26,9",
"comparison": "crosses_above",
"value": 0
}
]
}
}
}
// Enter when histogram crosses from negative to positive
MACD Divergence
Bullish Divergence:
- Price makes lower low
- MACD makes higher low
- Signal: Potential reversal to upside
Bearish Divergence:
- Price makes higher high
- MACD makes lower high
- Signal: Potential reversal to downside
Average Directional Index (ADX)
Calculation
ADX measures trend strength regardless of direction, helping traders determine if a market is trending or ranging.
Formula:
Step 1: Calculate True Range (TR)
TR = max[(High - Low), |High - Close_prev|, |Low - Close_prev|]
Step 2: Calculate Directional Movement
+DM = High - High_prev (if positive, else 0)
-DM = Low_prev - Low (if positive, else 0)
Step 3: Smooth and Calculate Directional Indicators
+DI = (Smoothed +DM / ATR) × 100
-DI = (Smoothed -DM / ATR) × 100
Step 4: Calculate DX
DX = (|+DI - -DI| / (+DI + -DI)) × 100
Step 5: Calculate ADX
ADX = Smoothed average of DX (typically 14 periods)
Characteristics
- Range: 0 to 100
- Weak Trend: ADX < 20
- Developing Trend: ADX 20-25
- Strong Trend: ADX 25-50
- Very Strong Trend: ADX > 50
- Extreme: ADX > 75 (rare)
- Period: 14 (standard)
Interpretation
| ADX Value | Trend Strength | Trading Strategy |
|---|---|---|
| 0-20 | No trend / Ranging | Avoid trend-following, use range strategies |
| 20-25 | Weak trend | Caution, wait for confirmation |
| 25-50 | Strong trend | Trend-following strategies work well |
| 50-75 | Very strong trend | Ride the trend, avoid counter-trend |
| 75-100 | Extremely strong | Trend exhaustion possible |
Directional Indicators
| Condition | Signal |
|---|---|
| +DI > -DI | Uptrend |
| -DI > +DI | Downtrend |
| +DI crosses above -DI | Bullish signal |
| -DI crosses above +DI | Bearish signal |
Usage Examples
Strong Trend Filter:
{
"type": "indicator_value",
"indicator": "adx",
"period": 14,
"comparison": "above",
"value": 25
}
// ADX > 25 = strong trend, safe for trend-following
Uptrend Confirmation:
{
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "adx",
"period": 14,
"comparison": "above",
"value": 25
},
{
"indicator1": "plus_di",
"period1": 14,
"indicator2": "minus_di",
"period2": 14,
"comparison": "above"
}
]
}
// ADX > 25 AND +DI > -DI = strong uptrend
DI Crossover:
{
"indicator1": "plus_di",
"period1": 14,
"indicator2": "minus_di",
"period2": 14,
"comparison": "crosses_above"
}
// +DI crosses above -DI = bullish signal
ADX Strategies
1. ADX Trend Filter:
{
"entryConditions": {
"long": {
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "adx",
"period": 14,
"comparison": "above",
"value": 25
},
{
"indicator1": "ema",
"period1": 20,
"indicator2": "ema",
"period2": 50,
"comparison": "crosses_above"
}
]
}
}
}
// Only take EMA crossover when ADX confirms strong trend
2. ADX with Directional Indicators:
{
"entryConditions": {
"long": {
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "adx",
"period": 14,
"comparison": "above",
"value": 20
},
{
"indicator1": "plus_di",
"period1": 14,
"indicator2": "minus_di",
"period2": 14,
"comparison": "crosses_above"
}
]
}
}
}
// Enter when +DI crosses above -DI with ADX > 20
Parabolic SAR (Stop and Reverse)
Calculation
Parabolic SAR provides potential entry and exit points by placing dots above or below price, indicating trend direction.
Formula:
SAR_tomorrow = SAR_today + AF × (EP - SAR_today)
Where:
- AF = Acceleration Factor (starts at 0.02, increases by 0.02 each period, max 0.20)
- EP = Extreme Point (highest high in uptrend, lowest low in downtrend)
- SAR = Stop and Reverse point
Example:
Uptrend:
Day 1: SAR = 100, EP = 105, AF = 0.02
Day 2: SAR = 100 + 0.02 × (105 - 100) = 100.10
If new high is made:
Day 3: EP = 106, AF = 0.04
Day 3: SAR = 100.10 + 0.04 × (106 - 100.10) = 100.34
If price closes below SAR:
Trend reverses, SAR switches to above price
Characteristics
- Position: Dots below price (uptrend), above price (downtrend)
- Acceleration Factor: 0.02 to 0.20 (standard)
- Best For: Trending markets
- Weakness: Whipsaws in ranging markets
- Use: Trailing stops, trend identification
Interpretation
| Condition | Signal |
|---|---|
| SAR below price | Uptrend, hold long |
| SAR above price | Downtrend, hold short |
| Price crosses below SAR | Exit long, enter short |
| Price crosses above SAR | Exit short, enter long |
Usage Examples
Uptrend Confirmation:
{
"type": "price_indicator",
"price": "close",
"indicator": "parabolic_sar",
"comparison": "above"
}
// Price above SAR = uptrend
Trend Reversal (Bullish):
{
"type": "price_indicator",
"price": "close",
"indicator": "parabolic_sar",
"comparison": "crosses_above"
}
// Price crosses above SAR = bullish reversal
Trailing Stop:
{
"exitConditions": {
"stopLoss": {
"type": "indicator",
"indicator": "parabolic_sar"
}
}
}
// Use SAR as trailing stop loss
Parabolic SAR Strategies
1. SAR Reversal System:
{
"entryConditions": {
"long": {
"conditions": [
{
"type": "price_indicator",
"price": "close",
"indicator": "parabolic_sar",
"comparison": "crosses_above"
}
]
},
"short": {
"conditions": [
{
"type": "price_indicator",
"price": "close",
"indicator": "parabolic_sar",
"comparison": "crosses_below"
}
]
}
},
"exitConditions": {
"oppositeSignal": {
"enabled": true,
"closeImmediately": true
}
}
}
// Enter on SAR flip, exit on opposite signal
2. SAR with Trend Filter:
{
"entryConditions": {
"long": {
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"price": "close",
"indicator": "ema",
"period": 200,
"comparison": "above"
},
{
"type": "price_indicator",
"price": "close",
"indicator": "parabolic_sar",
"comparison": "crosses_above"
}
]
}
}
}
// Only take SAR signals in direction of 200 EMA
Comparison: MACD vs ADX vs Parabolic SAR
| Feature | MACD | ADX | Parabolic SAR |
|---|---|---|---|
| Purpose | Momentum & trend changes | Trend strength | Trend direction & stops |
| Range | Unbounded | 0-100 | Price-based |
| Signals | Crossovers, divergences | Strength levels | Price crosses |
| Best For | Entry timing | Trend confirmation | Trailing stops |
| Lag | Medium | High | Low |
| Ranging Markets | Poor | Excellent (identifies) | Poor |
| Trending Markets | Good | Excellent | Excellent |
Trend Indicator Combinations
1. MACD + ADX (Momentum with Strength)
Setup:
- MACD(12,26,9) for entry signals
- ADX(14) for trend strength filter
Entry (Long):
- ADX > 25 (strong trend)
- MACD crosses above signal line
{
"entryConditions": {
"long": {
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "adx",
"period": 14,
"comparison": "above",
"value": 25
},
{
"indicator1": "macd",
"period1": "12,26,9",
"indicator2": "macd_signal",
"period2": "12,26,9",
"comparison": "crosses_above"
}
]
}
}
}
2. MACD + Parabolic SAR (Momentum with Stops)
Setup:
- MACD(12,26,9) for entries
- Parabolic SAR for trailing stops
Entry (Long):
- MACD crosses above signal
- Price above SAR
Exit:
- Price crosses below SAR
{
"entryConditions": {
"long": {
"logicalOperator": "AND",
"conditions": [
{
"indicator1": "macd",
"period1": "12,26,9",
"indicator2": "macd_signal",
"period2": "12,26,9",
"comparison": "crosses_above"
},
{
"type": "price_indicator",
"price": "close",
"indicator": "parabolic_sar",
"comparison": "above"
}
]
}
},
"exitConditions": {
"stopLoss": {
"type": "indicator",
"indicator": "parabolic_sar"
}
}
}
3. Triple Trend Confirmation
Setup:
- MACD for momentum
- ADX for strength
- +DI/-DI for direction
Entry (Long):
- MACD > 0
- ADX > 25
- +DI > -DI
{
"entryConditions": {
"long": {
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "macd",
"period": "12,26,9",
"comparison": "above",
"value": 0
},
{
"type": "indicator_value",
"indicator": "adx",
"period": 14,
"comparison": "above",
"value": 25
},
{
"indicator1": "plus_di",
"period1": 14,
"indicator2": "minus_di",
"period2": 14,
"comparison": "above"
}
]
}
}
}
Best Practices
Do's
- ✅ Use MACD for entry timing in trending markets
- ✅ Use ADX to filter out ranging markets (ADX < 20)
- ✅ Use Parabolic SAR for trailing stops
- ✅ Combine trend indicators with momentum indicators
- ✅ Wait for candle close before acting on signals
- ✅ Use longer periods for higher timeframes
Don'ts
- ❌ Use MACD or SAR in ranging markets (many false signals)
- ❌ Ignore ADX when trend-following (leads to whipsaws)
- ❌ Use Parabolic SAR alone without confirmation
- ❌ Trade against strong trends (ADX > 50)
- ❌ Over-optimize indicator parameters
- ❌ Use all three indicators together (redundant)
Common Pitfalls
1. MACD Whipsaws in Ranging Markets
Problem: Multiple false crossovers Solution: Use ADX filter (only trade when ADX > 25)
2. ADX Lag
Problem: ADX confirms trend after it's already started Solution: Use ADX as filter, not entry signal
3. Parabolic SAR Flips Too Often
Problem: Frequent reversals in choppy markets Solution: Combine with trend filter (EMA or ADX)
Related Documentation
- Indicators Overview - All available indicators
- Moving Averages - SMA, EMA, WMA
- Momentum Indicators - RSI, Stochastic, CCI
- How to Setup MACD Signals - Practical guide