Indicator · Pine Script v5 · On the chart

Extreme Trend Reversal Points [HeWhoMustNotBeNamed]

by theonetrade· code credited to HeWhoMustNotBeNamed

Extreme Trend Reversal Points [HeWhoMustNotBeNamed] is an overlay indicator designed to identify potential trend exhaustion and reversal levels on the price chart.

View on GitHub

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code133
Settings8inputs
LicenceMIT
Last update2 weeks ago8 Nov 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

133 lines of Pine Script v5 from assets/indicator/bit-exact/extreme_trend_reversal_points_hewhomustnotbenamed_eBB5mW6b.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

extreme_trend_reversal_points_hewhomustnotbenamed_eBB5mW6b.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed

//   __    __            __       __  __                  __       __                        __      __    __              __      _______             __    __                                          __ 
//  /  |  /  |          /  |  _  /  |/  |                /  \     /  |                      /  |    /  \  /  |            /  |    /       \           /  \  /  |                                        /  |
//  $$ |  $$ |  ______  $$ | / \ $$ |$$ |____    ______  $$  \   /$$ | __    __   _______  _$$ |_   $$  \ $$ |  ______   _$$ |_   $$$$$$$  |  ______  $$  \ $$ |  ______   _____  ____    ______    ____$$ |
//  $$ |__$$ | /      \ $$ |/$  \$$ |$$      \  /      \ $$$  \ /$$$ |/  |  /  | /       |/ $$   |  $$$  \$$ | /      \ / $$   |  $$ |__$$ | /      \ $$$  \$$ | /      \ /     \/    \  /      \  /    $$ |
//  $$    $$ |/$$$$$$  |$$ /$$$  $$ |$$$$$$$  |/$$$$$$  |$$$$  /$$$$ |$$ |  $$ |/$$$$$$$/ $$$$$$/   $$$$  $$ |/$$$$$$  |$$$$$$/   $$    $$< /$$$$$$  |$$$$  $$ | $$$$$$  |$$$$$$ $$$$  |/$$$$$$  |/$$$$$$$ |
//  $$$$$$$$ |$$    $$ |$$ $$/$$ $$ |$$ |  $$ |$$ |  $$ |$$ $$ $$/$$ |$$ |  $$ |$$      \   $$ | __ $$ $$ $$ |$$ |  $$ |  $$ | __ $$$$$$$  |$$    $$ |$$ $$ $$ | /    $$ |$$ | $$ | $$ |$$    $$ |$$ |  $$ |
//  $$ |  $$ |$$$$$$$$/ $$$$/  $$$$ |$$ |  $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$  |  $$ |/  |$$ |$$$$ |$$ \__$$ |  $$ |/  |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
//  $$ |  $$ |$$       |$$$/    $$$ |$$ |  $$ |$$    $$/ $$ | $/  $$ |$$    $$/ /     $$/   $$  $$/ $$ | $$$ |$$    $$/   $$  $$/ $$    $$/ $$       |$$ | $$$ |$$    $$ |$$ | $$ | $$ |$$       |$$    $$ |
//  $$/   $$/  $$$$$$$/ $$/      $$/ $$/   $$/  $$$$$$/  $$/      $$/  $$$$$$/  $$$$$$$/     $$$$/  $$/   $$/  $$$$$$/     $$$$/  $$$$$$$/   $$$$$$$/ $$/   $$/  $$$$$$$/ $$/  $$/  $$/  $$$$$$$/  $$$$$$$/ 
//                                                                                                                                                                                                          
//                                                                                                                                                                                                          
//
//@version=5
indicator("Extreme Trend Reversal Points [HeWhoMustNotBeNamed]", shorttitle = "ETRP[HWMNBN]", overlay=true)
import HeWhoMustNotBeNamed/_matrix/5 as ma
import HeWhoMustNotBeNamed/arrayutils/21 as ar
import HeWhoMustNotBeNamed/enhanced_ta/14 as eta
import HeWhoMustNotBeNamed/drawingutils/8 as dr
import HeWhoMustNotBeNamed/arrays/1 as pa

source = input.source(close, "Source", group="Moving Average")
type = input.string("sma", "Type", options = ["sma", "ema", "rma", "wma"], group="Moving Average")
length = input.int(20, "Length", step=5, group="Moving Average")
level = input.int(10, "Level", minval = 5, step=5, group="Moving Average")
minMaxRangePercentile = input.int(20, 'Range Percentile', minval=5, maxval=45, step=5)
extremeMinMaxRangePercentile = input.int(45, 'Extreme Range Percentile', minval=40, maxval=48, step=2)
history = input.int(1000, 'Percentile History', minval=1000, maxval=5000, step=500)
realTimeAlerts = input.bool(false, 'Real Time Alerts', 'If set to true, alerts are fired on latest candle - which may repaint. For safer option set this to false')
maxHistory = length-1

ema(float currentEma, float source, simple int length) =>
    k = 2 / (length + 1)
    ema = source * k + (1 - k) * currentEma
    ema

rma(float currentRma, float source, simple int length) =>
    k = 2 / (length + 1)
    rma = (currentRma * (length-1) + source)/length
    rma

var maMatrix = matrix.new<float>(1, level+1, source)

if(type == "ema")
    emaArray = array.new<float>(1, source)
    for i=1 to matrix.columns(maMatrix)-1
        ema = ema(matrix.get(maMatrix, 0, i), array.get(emaArray, array.size(emaArray)-1), length)
        array.push(emaArray, ema)
    ma.unshift(maMatrix, emaArray, maxHistory)

if(type == "rma")
    rmaArray = array.new<float>(1, source)
    for i=1 to matrix.columns(maMatrix)-1
        rma = rma(matrix.get(maMatrix, 0, i), array.get(rmaArray, array.size(rmaArray)-1), length)
        array.push(rmaArray, rma)
    ma.unshift(maMatrix, rmaArray, maxHistory)

if(type == "sma" or type == "wma")
    maArray = array.new<float>(1, source)
    for i=1 to matrix.columns(maMatrix)-1
        values = matrix.col(maMatrix, i-1)
        tmpArray = array.new<float>(1, array.get(maArray, i-1))
        tmpArray := array.concat(tmpArray, values)
        array.push(maArray, ar.ma(tmpArray, type, length))

    ma.unshift(maMatrix, maArray, maxHistory)

strength = 0
bearishStrength = 0
diffMatrix = matrix.new<float>(level+1, level+1, 0)

var linesArray = array.new<line>()
var labelsArray = array.new<label>()

ar.clear(linesArray)
ar.clear(labelsArray)

for i = 0 to level
    for j = 0 to level
        pma = matrix.get(maMatrix, 0, i)
        nma = matrix.get(maMatrix, 0, j)
        
        //strength := pma > nma ? strength+1 : strength
        if(j > i)
            strength := pma > nma ? strength+1 : strength
        matrix.set(diffMatrix, i, j, math.sign(pma-nma))
       
lastRow = matrix.row(maMatrix, 0)
lastRowIndex = array.sort_indices(array.slice(lastRow, 1, array.size(lastRow)), order.descending)

if(barstate.islast)
    for i=1 to level
        levelColor = color.from_gradient(i, 1, level, color.green, color.red)
        dr.draw_labelled_line(array.get(lastRow, i), type+'('+str.tostring(i)+')',levelColor, levelColor, 0, true, linesArray, labelsArray)

minRange = ta.percentile_nearest_rank(strength, history, 50-minMaxRangePercentile)
maxRange = ta.percentile_nearest_rank(strength, history, 50+minMaxRangePercentile)

extremeMinRange = ta.percentile_nearest_rank(strength, history, 50-extremeMinMaxRangePercentile)
extremeMaxRange = ta.percentile_nearest_rank(strength, history, 50+extremeMinMaxRangePercentile)
plotColor = strength > extremeMaxRange? color.green :
                 strength > maxRange? color.lime :
                 strength < extremeMinRange ? color.red : 
                 strength < minRange? color.orange : color.silver

strengthRange = strength > extremeMaxRange? 2 :
                 strength > maxRange? 1 :
                 strength > minRange ? 0 : 
                 strength < extremeMinRange? -1 : -2
maxStrength = level * (level+1)/2

ma = eta.ma(source, type, length)

bullishTrendReversalPoint = strength[1]== maxStrength and ta.crossunder(source, ma)
bearishTrendReversalPoint = strength[1]==0 and ta.crossover(source, ma)

plotshape(bullishTrendReversalPoint, 'Bullish Trend Reversal Point',
                     style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
plotshape(bearishTrendReversalPoint, 'Bearish Trend Reversal Point',
                     style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)

plot(strength, "Strength", color=color.silver, display = display.data_window)
plot(minRange, "Min Range", color=color.orange, display = display.data_window)
plot(maxRange, "Max Range", color=color.lime, display = display.data_window)
plot(extremeMinRange, "Extreme Min Range", color=color.red, display = display.data_window)
plot(extremeMaxRange, "Extreme Max Range", color=color.green, display = display.data_window)
plot(strengthRange, "Strength Range", color=color.blue, display = display.data_window)
plot(ma, "Moving Average", plotColor)

alertcondition(bullishTrendReversalPoint[realTimeAlerts?0:1], "Bullish Trend Reversal", "Possible reversal of bullish trend")
alertcondition(bearishTrendReversalPoint[realTimeAlerts?0:1], "Bearish Trend Reversal", "Possible reversal of bearish trend")

Overview

Extreme Trend Reversal Points [HeWhoMustNotBeNamed] processes moving average calculations—such as SMA, EMA, RMA, or WMA—alongside historical range percentiles evaluated across up to 5,000 historical bars. The indicator flags standard and extreme percentile thresholds to highlight turning points directly on price candles. Users can customize moving average smoothing, range percentiles, and history depth. An optional setting enables real-time alerts on active bars, which may repaint until bar close.

Details

Published by

theonetrade on GitHub

Code credit

HeWhoMustNotBeNamed, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

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.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

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

SettingTypeDefaultVariable
Sourcesourceclosesource
Typestringsmatype
Lengthint20length
Levelint10level
Range Percentileint20minMaxRangePercentile
Extreme Range Percentileint45extremeMinMaxRangePercentile
Percentile Historyint1000history
Real Time AlertsboolfalserealTimeAlerts
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

6 stars

This indicator classifies price action into four distinct market regimes: Trend, Expansion, Compression, or Mean Reversion. It determines states using a simplified Hurst exponent estimate, ADX slope thresholds, and realized volatility measurements. Based on th

Indicator v6 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of Capital41 Regime Matrix v3
1 stars

This indicator plots the original simple moving average, a symmetric moving average calculated from the highest and lowest moving averages over the window length, and a dynamic midline. It generates buy signals when the deviation from the symmetric moving aver

Indicator v5 Moving averagesTrend
Updated 2 months ago · None stated GitHub repository of Symmetric MA Reversal Signals

Trade Signal Indicator

by ashishgkwd
1 stars

Trade Signal Indicator is an overlay script that combines three tools: an EMA crossover (13 and 48 by default), an adaptive trend finder channel and a Nadaraya-Watson envelope. Each can be enabled separately, and colours, deviation multiplier, bandwidth and so

Indicator v6 TrendMoving averages Repaints
Updated 5 months ago · None stated GitHub repository of Trade Signal Indicator

A price-chart overlay that combines several tools. It draws a Nadaraya-Watson kernel envelope with a repainting smoothing option, a Hull moving average band in three variants that can optionally come from a higher timeframe, and an ATR trailing stop in the sty

Indicator v5 TrendMoving averages Repaints
Updated 1 year ago · None stated GitHub repository of UT Bot, Nadaraya-Watson, Hull Suite and Reversal Combo

MACD x RSI Study

by jerryinyang
5 stars

This indicator combines MACD and RSI to generate pullback signals on forex pairs. It plots MACD line, signal line and histogram alongside RSI and Wave Trend oscillator. Higher-timeframe MACD provides trend bias while RSI identifies overbought and oversold zone

Indicator v4 Oscillators & momentumMoving averages
Updated 2 years ago · None stated GitHub repository of MACD x RSI Study
947 stars

The Adaptive Laguerre Filter calculates a smoothed, dynamically adjusted trendline plotted directly on the main price chart. It dynamically adjusts its damping factor (alpha) based on recent price range variations and median percentile calculations over a spec

Indicator v4 TrendMoving averages
Updated 5 weeks ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter

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