What is the Elder-Ray Index?
The Elder-Ray Index, developed by Dr. Alexander Elder (author of "Trading for a Living"), is a technical indicator that measures the power of buyers and sellers in relation to a prevailing trend. It consists of three components:
- An Exponential Moving Average (EMA) (typically 13-period) which defines the trend.
- Bull Power: Measures the ability of buyers to push prices above the EMA.
- Bear Power: Measures the ability of sellers to push prices below the EMA.
The core idea behind the Elder-Ray Index is that an EMA acts as a flexible equilibrium price. Bull Power and Bear Power then quantify how far the actual price deviates from this equilibrium, indicating the strength of the underlying buying or selling pressure. It is typically displayed as two separate histograms, one for Bull Power and one for Bear Power, both oscillating around a zero line.
In Pine Script, the Elder-Ray Index is a valuable tool for traders seeking to understand the conviction behind price moves, identify potential reversals, and confirm trend strength by analyzing the relative power of bulls and bears.
Components and Calculation
The calculation of the Elder-Ray Index involves the following:
- EMA (Exponential Moving Average): This is the baseline for measurement.
`EMA_Value = ta.ema(close, length)` (e.g., 13 periods) - Bull Power: Measures the strength of buying pressure.
`Bull Power = High - EMA_Value`
This value is plotted as a histogram. Positive values indicate that bulls are pushing the price above the average; negative values mean the high is still below the average. - Bear Power: Measures the strength of selling pressure.
`Bear Power = Low - EMA_Value`
This value is also plotted as a histogram. Negative values indicate that bears are pushing the price below the average; positive values mean the low is still above the average.
Both Bull Power and Bear Power are often smoothed with an EMA themselves to reduce noise (e.g., a 13-period EMA of Bull Power and Bear Power, which is how TradingView's built-in version often operates).
Basic Elder-Ray Index Implementation in Pine Script
Pine Script v5 makes it straightforward to calculate the components of the Elder-Ray Index using `ta.ema()`.
//@version=5
indicator("My Elder-Ray Index", overlay=false, format=format.price) // overlay=false to plot in a separate pane
// Input for EMA length (often 13)
emaLength = input.int(13, title="EMA Length", minval=1)
// Calculate the EMA baseline
emaValue = ta.ema(close, emaLength)
// Calculate Bull Power
bullPower = high - emaValue
// Calculate Bear Power
bearPower = low - emaValue
// Plot Bull Power as a histogram
plot(bullPower, title="Bull Power", style=plot.style_columns, color=bullPower >= 0 ? color.green : color.red)
// Plot Bear Power as a histogram (typically inverted or distinct color)
plot(bearPower, title="Bear Power", style=plot.style_columns, color=bearPower <= 0 ? color.maroon : color.lime) // Using maroon for negative, lime for positive
// Plot the Zero Line
hline(0, "Zero Line", color.gray, linestyle=hline.style_solid)
Practical Elder-Ray Index Trading Strategies
1. Trend Confirmation with Bull and Bear Power
This strategy uses the direction of the EMA to define the trend, and then looks for Bull Power and Bear Power to confirm or diverge from that trend.
- In an Uptrend (EMA rising): Look for Bull Power to be positive and growing, confirming buying strength. Bear Power should ideally be negative or declining, indicating selling pressure is minimal.
- In a Downtrend (EMA falling): Look for Bear Power to be negative and growing, confirming selling strength. Bull Power should ideally be negative or declining, indicating buying pressure is minimal.
//@version=5
strategy("Elder-Ray Trend Confirmation", overlay=true)
emaLength = input.int(13, title="EMA Length", minval=1)
emaValue = ta.ema(close, emaLength)
// Plot EMA on price chart
plot(emaValue, "EMA", color.blue, linewidth=2, overlay=true)
bullPower = high - emaValue
bearPower = low - emaValue
// Plot Bull and Bear Power histograms in a separate pane
plot(bullPower, title="Bull Power", style=plot.style_columns, color=bullPower >= 0 ? color.green : color.gray, display=display.pane_only)
plot(bearPower, title="Bear Power", style=plot.style_columns, color=bearPower <= 0 ? color.red : color.gray, display=display.pane_only)
hline(0, "Zero Line", color.black, display=display.pane_only)
// Trend definition
isUptrend = emaValue > emaValue[1]
isDowntrend = emaValue < emaValue[1]
// Entry/Exit conditions based on trend and power
if (isUptrend and bullPower > 0 and bullPower > bullPower[1]) // Bullish trend, bull power increasing
strategy.entry("Long", strategy.long)
if (isDowntrend and bearPower < 0 and bearPower < bearPower[1]) // Bearish trend, bear power increasing
strategy.entry("Short", strategy.short)
// Example exit: if trend reverses or power wanes
if (isUptrend and (bearPower > 0 or bullPower < bullPower[1]))
strategy.close("Long")
if (isDowntrend and (bullPower < 0 or bearPower > bearPower[1]))
strategy.close("Short")
2. Reversal Signals with Bull Power
Even in a downtrend, Bull Power can signal potential bottoms or rallies if it starts to increase while still negative, or turns positive. This indicates buyers stepping in.
- Bullish Reversal Signal:
- An established downtrend (EMA falling).
- Bear Power is negative, but the last bar of Bear Power is *higher* than the previous bar (i.e., less negative, indicating weakening selling pressure).
- Bull Power forms a higher low (or rises from negative territory).
- Confirm with price action (e.g., price closing above EMA).
//@version=5
indicator("Elder-Ray Bull Power Reversal", overlay=true)
emaLength = input.int(13, title="EMA Length", minval=1)
emaValue = ta.ema(close, emaLength)
bullPower = high - emaValue
bearPower = low - emaValue
// Plot Bull and Bear Power histograms in a separate pane
plot(bullPower, title="Bull Power", style=plot.style_columns, color=bullPower >= 0 ? color.green : color.red)
plot(bearPower, title="Bear Power", style=plot.style_columns, color=bearPower <= 0 ? color.maroon : color.fuchsia)
hline(0, "Zero Line", color.gray)
// Check for downtrend (EMA falling)
isDowntrend = emaValue < emaValue[1]
// Bullish Reversal Condition (Simplified for example)
// Bear Power is negative but rising (less negative), Bull Power is making a higher low or turning positive
bullishReversalSignal = isDowntrend and bearPower > bearPower[1] and bullPower > bullPower[1] and bullPower[1] < 0
plotshape(bullishReversalSignal, title="Bull Reversal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
alertcondition(bullishReversalSignal, "Bullish Elder-Ray Reversal", "Potential bullish reversal based on Elder-Ray Bull Power.")
3. Reversal Signals with Bear Power
Conversely, even in an uptrend, Bear Power can signal potential tops or pullbacks if it starts to decline while still positive, or turns negative. This indicates sellers stepping in.
- Bearish Reversal Signal:
- An established uptrend (EMA rising).
- Bull Power is positive, but the last bar of Bull Power is *lower* than the previous bar (indicating weakening buying pressure).
- Bear Power forms a lower high (or falls into negative territory).
- Confirm with price action (e.g., price closing below EMA).
//@version=5
indicator("Elder-Ray Bear Power Reversal", overlay=true)
emaLength = input.int(13, title="EMA Length", minval=1)
emaValue = ta.ema(close, emaLength)
bullPower = high - emaValue
bearPower = low - emaValue
// Plot Bull and Bear Power histograms in a separate pane
plot(bullPower, title="Bull Power", style=plot.style_columns, color=bullPower >= 0 ? color.green : color.red)
plot(bearPower, title="Bear Power", style=plot.style_columns, color=bearPower <= 0 ? color.maroon : color.fuchsia)
hline(0, "Zero Line", color.gray)
// Check for uptrend (EMA rising)
isUptrend = emaValue > emaValue[1]
// Bearish Reversal Condition (Simplified for example)
// Bull Power is positive but falling, Bear Power is making a lower high or turning negative
bearishReversalSignal = isUptrend and bullPower < bullPower[1] and bearPower < bearPower[1] and bearPower[1] > 0
plotshape(bearishReversalSignal, title="Bear Reversal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
alertcondition(bearishReversalSignal, "Bearish Elder-Ray Reversal", "Potential bearish reversal based on Elder-Ray Bear Power.")
Optimizing Elder-Ray Index Performance
To get the most from the Elder-Ray Index in Pine Script:
- Trend is Paramount: Always use the EMA to determine the direction of the trend first. Only look for bullish signals in uptrends (or when an uptrend is beginning/confirming) and bearish signals in downtrends.
- Combine with Price Action: Elder-Ray works best when its signals are confirmed by price action. For example, a bullish Bull Power signal is stronger if the price forms a bullish candlestick pattern or breaks a short-term resistance.
- Divergence is Key: Pay close attention to divergence between Bull/Bear Power and price. If price makes a new high but Bull Power makes a lower high, it signals weakening buying pressure. If price makes a new low but Bear Power makes a higher low (less negative), it signals weakening selling pressure.
- Not a Standalone Indicator: Elder-Ray provides valuable insights into power, but it's not a complete system. Combine it with other indicators (e.g., volume, other momentum oscillators) for better confirmation and risk management.
- Parameter Tuning: The default 13-period EMA is widely used, but you can experiment with other lengths (e.g., 20 or 26) to suit different timeframes or asset volatilities.
Common Elder-Ray Index Pitfalls
- Whipsaws in Sideways Markets: In choppy or range-bound markets, the EMA will flatten, and Bull/Bear Power might oscillate frequently around zero, generating false signals. Elder-Ray performs best in trending environments.
- Lag: As it uses an EMA, the Elder-Ray Index has some inherent lag and will not pinpoint exact tops or bottoms immediately.
- Requires Understanding of Price Action: Interpreting Elder-Ray effectively often requires a good understanding of candlestick patterns and support/resistance levels.
- Subjectivity: Interpreting nuances like "higher low" or "lower high" in the histograms can sometimes be subjective without robust pivot detection.
- Not for Scalping: Due to its reliance on an EMA, it's generally not suited for very short-term scalping strategies.
Conclusion
The Elder-Ray Index is a powerful and insightful technical indicator in Pine Script for TradingView, designed by Dr. Alexander Elder to quantify the underlying strength of buyers and sellers relative to the prevailing trend. By dissecting market momentum into "Bull Power" and "Bear Power," it provides a unique perspective on the market's internal dynamics. Whether used for confirming trend strength, spotting early signs of reversal through power shifts, or identifying powerful divergences, the Elder-Ray Index offers valuable insights. By understanding its calculation, thoughtfully combining it with price action and the EMA trend filter, you can leverage this indicator to enhance your trading decisions and gain a deeper understanding of market forces.
Enhance Your Trading
Get a high-performance Pine Script analysis tool for actionable market insights, designed for traders on the move.
This strategy runs in live mode on TradingView, helping you identify potential opportunities.
Subscribe now @ $99/month