Indicator · Pine Script v6 · Own pane

IBD Power Trend

by major

This indicator tracks Investor's Business Daily style Power Trend rules and setup conditions in a separate pane.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code110
Settings12inputs
LicenceApache-2.0
Last update3 months ago29 Jul 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 indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

110 lines of Pine Script v6 from ibd_power_trend/ibd_power_trend.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

ibd_power_trend.pine
// Copyright 2026 Major Hayden
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//@version=6
indicator('IBD Power Trend', shorttitle = 'PowerTrend', overlay = false, precision = 0, max_bars_back = 250)

// ═══════════════════════════════════════════════════════════════
// INPUTS
// ═══════════════════════════════════════════════════════════════

grpSignal = 'Signal Settings'
emaLength = input.int(21, title = 'EMA Length', minval = 1, group = grpSignal, tooltip = 'Fast moving average used by the Power Trend rules')
smaLength = input.int(50, title = 'SMA Length', minval = 1, group = grpSignal, tooltip = 'Slow moving average used by the Power Trend rules')
lowAboveEmaDays = input.int(10, title = 'Low Above EMA Days', minval = 1, group = grpSignal, tooltip = 'Number of trading days where each bar low must stay above the fast EMA')
emaAboveSmaDays = input.int(5, title = 'EMA Above SMA Days', minval = 2, group = grpSignal, tooltip = 'Number of trading days where the fast EMA must stay above the slow SMA before a full Power Trend can begin')
smaRisingLookback = input.int(5, title = 'SMA Rising Lookback', minval = 1, group = grpSignal, tooltip = 'Slow SMA must be higher than it was this many trading days ago')
highLookback = input.int(63, title = 'Recent High Lookback', minval = 1, group = grpSignal, tooltip = 'Lookback used for the Power Trend sell-off stop rule')
highDrawdownPercent = input.float(10.0, title = 'Recent High Drawdown (%)', minval = 0.1, maxval = 100.0, step = 0.1, group = grpSignal, tooltip = 'Power Trend ends when close is at least this far below the recent high and below the slow SMA')

grpVisual = 'Visual Settings'
showPowerTrendMarkers = input.bool(true, title = 'Show Power Trend Circles', group = grpVisual, tooltip = 'Show circles while the Power Trend is active')
showSetupWarningMarkers = input.bool(true, title = 'Show Almost Power Trend Circles', group = grpVisual, tooltip = 'Show yellow circles when the chart is close enough to a Power Trend to watch closely')
powerTrendColor = input.color(color.lime, title = 'Power Trend Color', group = grpVisual)
almostPowerTrendColor = input.color(color.yellow, title = 'Almost Power Trend Color', group = grpVisual)
showZeroLine = input.bool(true, title = 'Show Zero Line', group = grpVisual)

// ═══════════════════════════════════════════════════════════════
// CALCULATIONS
// ═══════════════════════════════════════════════════════════════

ema21 = ta.ema(close, emaLength)
sma50 = ta.sma(close, smaLength)

// Each bar's low must be above that same bar's EMA for the full lookback. The
// almost signal allows one missing day because these charts are worth watching
// before every rule is perfect.
lowAboveEmaCount = math.sum(low >= ema21 ? 1 : 0, lowAboveEmaDays)
lowAboveEma = lowAboveEmaCount == lowAboveEmaDays
lowAboveEmaAlmost = lowAboveEmaCount >= lowAboveEmaDays - 1

// The fast EMA must stay above the slow SMA for the full lookback. A one-day
// shorter run is close enough for a watchlist warning.
emaAboveSmaCurrent = ema21 > sma50
emaAboveSmaCount = math.sum(emaAboveSmaCurrent ? 1 : 0, emaAboveSmaDays)
emaAboveSma = emaAboveSmaCount == emaAboveSmaDays
emaAboveSmaAlmost = emaAboveSmaCount >= emaAboveSmaDays - 1

// Compare the slow SMA to several trading days ago to avoid reacting to a one-bar wiggle.
smaRising = sma50 > sma50[smaRisingLookback]
closeUp = close > close[1]

startPowerTrend = lowAboveEma and emaAboveSma and smaRising and closeUp
almostPowerTrendSetup = lowAboveEmaAlmost and emaAboveSmaAlmost and smaRising and not startPowerTrend

emaCrossedBelowSma = ta.crossunder(ema21, sma50)
recentHigh = ta.highest(high, highLookback)
drawdownStop = close < recentHigh * (1.0 - highDrawdownPercent / 100.0) and close < sma50
endPowerTrend = emaCrossedBelowSma or drawdownStop

var bool powerTrend = false
if startPowerTrend
    powerTrend := true
if endPowerTrend
    powerTrend := false

newPowerTrend = powerTrend and not powerTrend[1]
almostPowerTrend = almostPowerTrendSetup and not powerTrend
newAlmostPowerTrend = almostPowerTrend and not almostPowerTrend[1]

showPowerMarker = powerTrend and showPowerTrendMarkers
showSetupMarker = almostPowerTrend and showSetupWarningMarkers
markerValue = showPowerMarker or showSetupMarker ? 0 : na
markerColor = showPowerMarker ? powerTrendColor : showSetupMarker ? almostPowerTrendColor : na

// ═══════════════════════════════════════════════════════════════
// VISUAL OUTPUT
// ═══════════════════════════════════════════════════════════════

hline(0, title = 'Zero Line', color = showZeroLine ? color.new(color.gray, 70) : color.new(color.gray, 100), editable = false)

// Screener-friendly numeric outputs. Keep the two primary booleans first so they
// are easy to filter in Pine Screener.
plot(powerTrend ? 1 : 0, title = 'Power Trend Active', display = display.data_window, editable = false)
plot(almostPowerTrend ? 1 : 0, title = 'Almost Power Trend', display = display.data_window, editable = false)
plot(newPowerTrend ? 1 : 0, title = 'New Power Trend', display = display.data_window, editable = false)
plot(newAlmostPowerTrend ? 1 : 0, title = 'New Almost Power Trend', display = display.data_window, editable = false)
plot(lowAboveEma ? 1 : 0, title = 'Low Above EMA', display = display.data_window, editable = false)
plot(emaAboveSma ? 1 : 0, title = 'EMA Above SMA', display = display.data_window, editable = false)
plot(smaRising ? 1 : 0, title = 'SMA Rising', display = display.data_window, editable = false)
plot(closeUp ? 1 : 0, title = 'Close Up', display = display.data_window, editable = false)

plot(markerValue, title = 'Power Trend Circles', color = markerColor, linewidth = 4, style = plot.style_circles, editable = false)

// ═══════════════════════════════════════════════════════════════
// ALERTS
// ═══════════════════════════════════════════════════════════════

alertcondition(newPowerTrend, title = 'New IBD Power Trend', message = '{{ticker}}: New IBD Power Trend started')
alertcondition(newAlmostPowerTrend, title = 'IBD Almost Power Trend', message = '{{ticker}}: IBD Power Trend setup is close enough to watch closely')

Overview

IBD Power Trend evaluates whether price lows hold above an exponential moving average, verifies that the fast EMA remains above a rising simple moving average, and monitors for sell-off stop conditions based on drawdown from recent highs. When active, it plots status circles on a zero line for active trends and setup phases. Inputs allow configuring moving average periods, duration filters, drawdown percentages, and visual colors.

Details

Published by

major on GitHub

Draws

Separate pane below the chart

Markets

Stocks, Indices

Timeframes

H4 and above, M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

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

SettingTypeDefaultVariable
EMA Lengthint21emaLength
SMA Lengthint50smaLength
Low Above EMA Daysint10lowAboveEmaDays
EMA Above SMA Daysint5emaAboveSmaDays
SMA Rising Lookbackint5smaRisingLookback
Recent High Lookbackint63highLookback
Recent High Drawdown (%)float10.0highDrawdownPercent
Show Power Trend CirclesbooltrueshowPowerTrendMarkers
Show Almost Power Trend CirclesbooltrueshowSetupWarningMarkers
Power Trend Colorcolorcolor.limepowerTrendColor
Almost Power Trend Colorcolorcolor.yellowalmostPowerTrendColor
Show Zero LinebooltrueshowZeroLine
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

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop
228 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of MultiIndicator
99 stars

Calculates the Archer Moving Averages Trends (AMAT) indicator by comparing fast and slow Exponential Moving Averages (EMAs) alongside their slope directions. A bullish trend (+1) is identified when the fast EMA exceeds the slow EMA with both rising, while a be

Indicator v6 TrendMoving averages
Updated 4 weeks ago · Apache-2.0 GitHub repository of Archer Moving Averages Trends (AMAT)

Colored fill

by be-thomas
65 stars

This indicator plots two simple moving averages of close, one over five bars and one over twenty bars, in a separate pane. It shades the area between the two plots green when the shorter average is above the longer average and red when it is below. There are n

Indicator v4 Moving averagesTrend
Updated 6 days ago · GPL-3.0 GitHub repository of Colored fill

More Trend scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers