Indicator · Pine Script v5 · On the chart

Hotch Strat

by rajatjpatel· code credited to plewis22782

A Pine v5 overlay that detects Williams-style fractals over an adjustable period and filters them by a recent RSI extreme.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code91
Settings4inputs
LicenceNone statedfile: MPL-2.0
Last update4 years ago18 Oct 2022

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

91 lines of Pine Script v5 from message (4).txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

message (4).txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © plewis22782
//@version=5
//
indicator("Hotch Strat", overlay=true)
//--------------------------------------------------------------Code Insert----------------------------------------------------------
// Define "n" as the number of periods and keep a minimum value of 2 for error handling.
n = input.int(title="Periods", defval=2, minval=2)


// UpFractal
bool upflagDownFrontier = true
bool upflagUpFrontier0 = true
bool upflagUpFrontier1 = true
bool upflagUpFrontier2 = true
bool upflagUpFrontier3 = true
bool upflagUpFrontier4 = true

for i = 1 to n
    upflagDownFrontier := upflagDownFrontier and (high[n-i] < high[n])
    upflagUpFrontier0 := upflagUpFrontier0 and (high[n+i] < high[n])
    upflagUpFrontier1 := upflagUpFrontier1 and (high[n+1] <= high[n] and high[n+i + 1] < high[n])
    upflagUpFrontier2 := upflagUpFrontier2 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+i + 2] < high[n])
    upflagUpFrontier3 := upflagUpFrontier3 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+i + 3] < high[n])
    upflagUpFrontier4 := upflagUpFrontier4 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+4] <= high[n] and high[n+i + 4] < high[n])
flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4

upFractal = (upflagDownFrontier and flagUpFrontier)


// downFractal
bool downflagDownFrontier = true
bool downflagUpFrontier0 = true
bool downflagUpFrontier1 = true
bool downflagUpFrontier2 = true
bool downflagUpFrontier3 = true
bool downflagUpFrontier4 = true

for i = 1 to n
    downflagDownFrontier := downflagDownFrontier and (low[n-i] > low[n])
    downflagUpFrontier0 := downflagUpFrontier0 and (low[n+i] > low[n])
    downflagUpFrontier1 := downflagUpFrontier1 and (low[n+1] >= low[n] and low[n+i + 1] > low[n])
    downflagUpFrontier2 := downflagUpFrontier2 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+i + 2] > low[n])
    downflagUpFrontier3 := downflagUpFrontier3 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+i + 3] > low[n])
    downflagUpFrontier4 := downflagUpFrontier4 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+4] >= low[n] and low[n+i + 4] > low[n])
flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4

downFractal = (downflagDownFrontier and flagDownFrontier)



//get user inputs

rsiSource = input.source(title="RSI Source", defval=close)
rsiLength = input.int(title="RSI Length", defval=14)
rsiLookback = input.int(title="RSI Lookback", defval=3)
//Get RSI Value

rsiValue = ta.rsi(rsiSource, rsiLength)


ifRsiB40 = ta.lowest(rsiValue,rsiLookback)<= 40 and ta.lowest(rsiValue,rsiLookback)>30
ifRsiB30 = ta.lowest(rsiValue,rsiLookback)<= 30 and ta.lowest(rsiValue,rsiLookback)>20
ifRsiB20 = ta.lowest(rsiValue,rsiLookback)<= 20 and ta.lowest(rsiValue,rsiLookback)>0



plotB40 = ifRsiB40 and (downflagDownFrontier and flagDownFrontier)
plotB30 = ifRsiB30 and (downflagDownFrontier and flagDownFrontier)
plotB20 = ifRsiB20 and (downflagDownFrontier and flagDownFrontier)


plotshape(plotB40,  location=location.belowbar, offset=-n, color=#B0FF9E, style=shape.triangleup, size = size.small )  
plotshape(plotB30,  location=location.belowbar, offset=-n, color=#1EFF00, style=shape.triangleup, size = size.small )  
plotshape(plotB20,  location=location.belowbar, offset=-n, color=#0A5200, style=shape.triangleup, size = size.small )  



ifRsiO60 = ta.highest(rsiValue,rsiLookback)>= 60 and ta.highest(rsiValue,rsiLookback)<70
ifRsiO70 = ta.highest(rsiValue,rsiLookback)>= 70 and ta.highest(rsiValue,rsiLookback)<80
ifRsiO80 =ta.highest(rsiValue,rsiLookback)>= 80 and ta.highest(rsiValue,rsiLookback)<100


plotO60 = ifRsiO60 and (upflagDownFrontier and flagUpFrontier)
plotO70 = ifRsiO70 and (upflagDownFrontier and flagUpFrontier)
plotO80 = ifRsiO80 and (upflagDownFrontier and flagUpFrontier)


plotshape(plotO60,  location=location.abovebar, offset=-n, color=#FF9B94, style=shape.triangledown, size = size.small )
plotshape(plotO70,  location=location.abovebar, offset=-n, color=#FF0008, style=shape.triangledown, size = size.small )
plotshape(plotO80,  location=location.abovebar, offset=-n, color=#750004,

Overview

When a down fractal forms after RSI dipped into the 20s, 30s or 40s over the lookback, an up triangle of a matching shade is drawn below the bar. Mirror logic appears intended for highs. The period, RSI source, RSI length and RSI lookback are adjustable. Markers show only after the fractal is confirmed, a few bars after the pivot.

Details

Published by

rajatjpatel on GitHub

Code credit

plewis22782, 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.

Settings

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

SettingTypeDefaultVariable
Periodsint2n
RSI SourcesourceclosersiSource
RSI Lengthint14rsiLength
RSI Lookbackint3rsiLookback
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

PivotHighLow

by Alorse
330 stars

This indicator calculates pivot high and pivot low points on the price chart based on configurable left and right bar counts. Confirmed pivot highs and lows are plotted with negative bar offsets directly on the price chart using line and cross styles. Addition

Indicator v4 Support & resistanceOscillators & momentum Repaints
Updated 2 months ago · None stated GitHub repository of PivotHighLow
114 stars

This indicator calculates key support and resistance levels by analyzing the first and second momentum derivatives of a Double Exponential Moving Average (DEMA). When the second derivative (momentum of momentum) crosses zero, it identifies local turning points

Indicator v4 Support & resistanceOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Support and Resistance Levels

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 2 months ago · Custom licence GitHub repository of Moon Dev Lunar Sniper
23 stars

This indicator collection calculates and plots previous daily high and low price levels on the chart to identify potential supply and demand zones. It includes real-time intraday high and low calculations, RSI divergence detection across a customizable period

Indicator v4 Support & resistanceDivergence
Updated 3 years ago · None stated GitHub repository of Daily High and Low Strategy
14 stars

Self-Aware Trend System calculates volatility-adaptive ATR trailing bands using a Trend Quality Index engine that evaluates market efficiency, momentum persistence, and structural pivots. It plots adaptive trend bands and character-flip trend signals directly

Indicator v6 TrendVolatility & bands
Updated 3 weeks ago · MIT GitHub repository of Self-Aware Trend System [WillyAlgoTrader]

More Oscillators & momentum 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