An indicator that detects cup and handle patterns from pivots, with inputs for rim similarity, handle retracement range, an invalidation retrace level and a target set as a multiple of cup depth.
1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.
Overview
A Bayesian probability update using a Bollinger squeeze as evidence must pass a posterior threshold. Target and stop boxes, pattern labels and a multi-timeframe dashboard are drawn on the price chart, and an automatic cleanup removes older drawings. Despite the name, nothing in the code limits it to one asset.
Cup and handle detection from pivots
Bayesian probability with Bollinger squeeze evidence
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Pivot span
int
10
pivotSpan
Rim similarity tolerance (%)
int
18
rimTolPct
Handle retrace min
float
0.12
hMin
Handle retrace max
float
0.55
hMax
Invalidation retrace (%)
float
61.8
killAtFib
Require breakout confirmation
bool
false
needConfirm
Target multiplier (× cup depth)
float
0.75
targetMult
Prior probability P(H)
float
0.35
pPrior
Likelihood P(E|H)
float
0.75
pSqueezeLik
Likelihood P(E|¬H)
float
0.40
pNoiseLik
Posterior threshold
float
0.60
probThresh
Bollinger length
int
20
bbLength
Show all 28 settings
Setting
Type
Default
Variable
Bollinger deviation
float
2.0
bbMult
Show MTF dashboard
bool
true
showTable
GC sweep trigger
int
6
gcThreshold
Max retained patterns
int
20
gcKeep
Cluster buckets
int
8
gcBuckets
Show pattern label
bool
true
showName
Show target line/boxes
bool
true
showTarget
Show target/stop boxes
bool
true
showZones
Bull fill
color
color.new(color.lime, 84)
bgBull
Bull line
color
color.new(color.lime, 15)
lnBull
Bear fill
color
color.new(color.red, 84)
bgBear
Bear line
color
color.new(color.red, 15)
lnBear
Pattern width
int
2
wOk
Pattern style
string
Solid
stOk
Target width
int
2
targetWidth
Target style
string
Dashed
targetStyle
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.
This indicator calculates and plots Donchian Channels directly on the price chart. It determines the highest high and lowest low over a user-selected lookback period using an optimized monotonic deque algorithm, as well as a middle basis line computed as their
The Donchian Channels indicator plots the middle basis line as the average of the high and low over the user-defined period. It also draws the upper band as the highest high and the lower band as the lowest low across the same period on the price chart. The ma
This indicator plots Donchian channel bands and a midline on the price chart. It finds the highest and lowest values over a user-set length, then draws the upper band, lower band, and their average as the basis. The source setting chooses high and low, or the
This overlay indicator measures average bar range as a simple moving average of high minus low, then draws short horizontal ticks at one to four times that range above and below the close. The user chooses which multipliers appear, their colors, and the line w
This indicator identifies and plots price compression zones directly on the price chart using multi-module scoring. It measures ATR compression, ADX chop levels, boundary touches, volume dry-up, and historical pivot levels to identify consolidation areas and s
The Dereköy-Darvas indicator combines Darvas Box boundary levels with dual Bollinger Bands plotted directly on the main price chart. It calculates top and bottom box lines based on recent high and low extremes to outline price consolidation zones. Simultaneous