Strategy · Pine Script v6 · Own pane

Elder Ray Index

by pineforge-4pass· code credited to PineForge contributors 2026

Calculates Elder Ray Bull Power and Bear Power by measuring differences between price extremes and an exponential moving average.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code45
Settings1inputs
LicenceApache-2.0
Last update5 days ago23 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

45 lines of Pine Script v6 from validation/ta-elder-ray-bull-bear-power-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF probe 11 — Elder Ray bull/bear power
// Purpose: parity test for ta.ema() + (high|low - ema) bull/bear power chain
// with `[1]`-history rising/falling memory and trend-EMA gate.
//
//@version=6
strategy("Elder Ray Index", overlay=false, initial_capital=1000000, process_orders_on_close=false, pyramiding=1, commission_type=strategy.commission.percent, commission_value=0, slippage=0, default_qty_type=strategy.fixed, default_qty_value=1)

// === Inputs ===
emaLen = input.int(13, "EMA Length", minval=1)

// === Elder Ray: Bull/Bear Power ===
emaVal    = ta.ema(close, emaLen)
bullPower = high - emaVal
bearPower = low - emaVal

// === Trend filter ===
emaTrend = ta.ema(close, 50)
upTrend  = close > emaTrend
dnTrend  = close < emaTrend

// === Signals ===
// Long: uptrend + bear power negative but rising
longCond  = upTrend and bearPower < 0 and bearPower > bearPower[1]
// Short: downtrend + bull power positive but falling
shortCond = dnTrend and bullPower > 0 and bullPower < bullPower[1]

// === Strategy ===
if longCond
    strategy.entry("Long", strategy.long)
if shortCond
    strategy.entry("Short", strategy.short)

// === Exit ===
if strategy.position_size > 0 and bearPower > 0 and bearPower < bearPower[1]
    strategy.close("Long")
if strategy.position_size < 0 and bullPower < 0 and bullPower > bullPower[1]
    strategy.close("Short")

plot(bullPower, "Bull Power", color=color.green, style=plot.style_histogram)
plot(bearPower, "Bear Power", color=color.red, style=plot.style_histogram)
hline(0, "Zero")

Overview

Elder Ray Index takes long entries during an uptrend when Bear Power is negative but rising, and short entries during a downtrend when Bull Power is positive but falling. Long and short positions close based on Bear Power or Bull Power reversals. Plots Bull Power and Bear Power as histograms in a separate pane. The strategy relies on technical exits without hard stop-loss orders.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Type

Strategy, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
EMA Lengthint13emaLen
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

330 stars

MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points. It filters trade signals with dual Exponential Moving Averages (EMA 150 and 600) to ensure tra

Strategy v4 Oscillators & momentumDivergence Repaints
Updated 2 months ago · None stated GitHub repository of MACD + Divergences [Alorse]

MACD Crossover (tutorial)

by pineforge-4pass
193 stars

This strategy calculates the Moving Average Convergence Divergence indicator and plots the MACD line, signal line, and histogram in a separate pane. It enters long positions when the MACD line crosses above the signal line and enters short positions when it cr

Strategy v6 Oscillators & momentumMoving averages
Updated today · Apache-2.0 GitHub repository of MACD Crossover (tutorial)

ADX Strategy

by hasnocool
106 stars

An ADX-based trend-following strategy that enters long positions when the positive directional indicator (DI+) crosses above the Average Directional Index (ADX) while ADX remains below a preset threshold and a fast EMA is above a slow EMA. It allows adding to

Strategy v4 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of ADX Strategy

EMA Ribbon MACD

by iamrichardD
57 stars

This strategy combines an EMA ribbon with MACD confirmation and plots in a separate pane. It enters when ribbon alignment, optional MACD zero or signal crosses, volume, smart-money, and multi-timeframe filters agree, then exits with percentage stop loss and ta

Strategy v6 TrendMoving averages
Updated 1 year ago · Apache-2.0 GitHub repository of EMA Ribbon MACD

This strategy evaluates the dynamic relationship between price and a chosen moving average across six diagnostic dimensions: trend, respect, extension, compression, acceleration, and exhaustion. It plots a normalized relationship oscillator bounded between -10

Strategy v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of Market–Average Relationship Engine [WavesUnchained]
7 stars

This strategy combines the Moving Average Convergence Divergence oscillator with an Exponential Moving Average trend filter. It enters long positions when the MACD histogram crosses above zero while price stays above the long-term EMA filter. Long trades close

Strategy v5 TrendOscillators & momentum
Updated 1 year ago · MPL-2.0 GitHub repository of MACD EMA Filter Strategy

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers