indicator · on price · open source
Change of Character (CHOCH)
Running…
Loading chart…
About
Change of Character (CHOCH) fires when price breaks structure against the prevailing trend — a higher low after a run of lower lows (bullish CHOCH) or a lower high after higher highs (bearish CHOCH).
- Often the first sign of a trend reversal.
- An optional
confirmClosefilter waits for the bar to close beyond the level. - Pairs well with order blocks and FVGs for reversal entries.
Source code
//@version=5
indicator("Change of Character (CHOCH)", overlay=true)
swing = input.int(5, "Swing Length", minval=2, maxval=50)
confirmClose = input.bool(true, "Confirm on Close")
ph = ta.pivothigh(high, swing, swing)
pl = ta.pivotlow(low, swing, swing)
var float lastPh = na
var float prevPh = na
var float lastPl = na
var float prevPl = na
var int trend = 0
if not na(ph)
prevPh := lastPh
lastPh := ph
if not na(prevPh) and ph < prevPh
trend := -1
else if not na(prevPh) and ph > prevPh
trend := 1
if not na(pl)
prevPl := lastPl
lastPl := pl
if not na(prevPl) and pl > prevPl
trend := 1
else if not na(prevPl) and pl < prevPl
trend := -1
bullChoch = trend == -1 and lastPl > prevPl and low < lastPh
bearChoch = trend == 1 and lastPh < prevPh and high > lastPl
bullChoch := confirmClose ? (bullChoch and close > lastPh) : bullChoch
bearChoch := confirmClose ? (bearChoch and close < lastPl) : bearChoch
plotshape(bullChoch and not bullChoch[1], "Bull CHOCH", style=shape.triangleup, location=location.belowbar, color=color.lime, text="CHOCH")
plotshape(bearChoch and not bearChoch[1], "Bear CHOCH", style=shape.triangledown, location=location.abovebar, color=color.maroon, text="CHOCH")
alertcondition(bullChoch and not bullChoch[1], "Bullish CHOCH", "Change of character to upside")
alertcondition(bearChoch and not bearChoch[1], "Bearish CHOCH", "Change of character to downside")
No comments yet.
Sign in to comment.