//----------------------------------------------------------------------//
//PRC_Reversal&Breakout Signals
//version = 0
//11.04.24
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//----------------------------------------------------------------------//
//-----Inputs-----------------------------------------------------------//
len=20//Indicator period
vlen=20//Volume Strength period
threshold=1.5//Stong Volume Threshold
trnd=1//Colour Candles During Trends
//----------------------------------------------------------------------//
//-----Hull moving average----------------------------------------------//
hma=hullaverage[30](close)
//----------------------------------------------------------------------//
//-----Volume conditions------------------------------------------------//
rvol=volume/average[vlen](volume)
strongvol=rvol>threshold
//----------------------------------------------------------------------//
//-----Weighted moving average------------------------------------------//
sh=weightedaverage[len](high)
sl=weightedaverage[len](low)
//----------------------------------------------------------------------//
//-----Channel----------------------------------------------------------//
ch=highest[len](sh)
cl=lowest[len](sl)
//----------------------------------------------------------------------//
//-----High and Low Levels definition-----------------------------------//
if not (ch<ch[1] or ch>ch[1]) then
hstore=ch[1]
elsif not (cl<cl[1] or cl>cl[1]) then
lstore=cl[1]
endif
midline=(hstore+lstore)/2
//----------------------------------------------------------------------//
//-----Candle direction-------------------------------------------------//
if close > open then
candledir = 1
else
candledir = -1
endif
//----------------------------------------------------------------------//
//-----Breaks and Reversals Definition---------------------------------//
breakout=candledir and close>hstore and open<hstore
breakdown=candledir=-1 and close<lstore and open>lstore
//-----Bullish BreakOut
bullishbreakout= (breakout or ((breakout[1] or breakout[2] or breakout[3] or breakout[4]) and candledir = 1)) and strongvol and not (bullishbreakout[1] or bullishbreakout[2] or bullishbreakout[3])
//-----Bearish BreakOut
bearishbreakout = (breakdown or ((breakdown[1] or breakdown[2] or breakdown[3] or breakdown[4]) and candledir = -1)) and strongvol and not (bearishbreakout[1] or bearishbreakout[2] or bearishbreakout[3])
//-----Bullish Reversal
bullishrej = (low < lstore and close > lstore) and not (bullishrej[1] or bullishrej[2] or bullishrej[3] or bullishrej[4])
//-----Bearish Reversal
bearishrej = (high > hstore and close < hstore) and not (bearishrej[1] or bearishrej[2] or bearishrej[3] or bearishrej[4])
//-----Trend Status
if bullishbreakout then
state=1
elsif bearishbreakout then
state=-1
elsif (low crosses over lstore and state=-1) or (high crosses under hstore and state=1) then
state=0
endif
//------------------------------------------------------------------------//
//-----Plot Trend Tracker and color Candles-------------------------------//
if state=-1 then
TrendTracker=hma
drawpoint(barindex,TrendTracker,1)coloured("red")
if trnd then
DRAWCANDLE(open, high, low, close)coloured("red")
endif
elsif state=1 then
TrendTracker=hma
drawpoint(barindex,TrendTracker,1)coloured("green")
if trnd then
DRAWCANDLE(open, high, low, close)coloured("green")
endif
else
TrendTracker=0
endif
//------------------------------------------------------------------------//
//-----Show Bullish and Bearish Reversals---------------------------------//
if bullishrej and not (state=-1) then
drawtext("▲",barindex,low-0.25*tr)coloured("green")
elsif bearishrej and not (state=1) then
drawtext("▼",barindex,high+0.25*tr)coloured("red")
endif
//------------------------------------------------------------------------//
//-----Show Bullish and Bearish Breakouts---------------------------------//
if bullishbreakout then
drawtext("♦",barindex,low-0.25*tr)coloured("yellow")
DRAWCANDLE(open, high, low, close)coloured("yellow")
elsif bearishbreakout then
drawtext("♦",barindex,high+0.25*tr)coloured("yellow")
DRAWCANDLE(open, high, low, close)coloured("yellow")
endif
//----------------------------------------------------------------------//
return hstore as "Upper Level" coloured("red",50)style(line,2), lstore as "Lower Level" coloured("green",50)style(line,2), midline as "Midline"coloured("grey",50)