Reversal zone finder
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MoriFX

//@version=4
study("Reversal zone finder", overlay=true)

// User inputs
longAlerts = input(title="Trigger Long Alerts", type=input.bool, defval=true)
shortAlerts = input(title="Trigger Short Alerts", type=input.bool, defval=true)
rsiOB = input(title="RSI OverBought Value", type=input.integer, defval=65)
rsiOS = input(title="RSI OverSold Value", type=input.integer, defval=35)

// Big candle detector
lastCandleSize = abs(high[1] - low[1])
curCandleSize = abs(high - low)

bullishCandle = (curCandleSize > (lastCandleSize * 1.5)) and (close > open)
bearishCandle = (curCandleSize > (lastCandleSize * 1.5)) and (close < open)

// RSI 
rsiValue = rsi(close[1],14)

// Plot signal
plotshape(bullishCandle and ((rsiValue[1] < rsiOS) or (rsiValue < rsiOS)) , color=color.green, style=shape.triangleup, size=size.tiny, location=location.belowbar)
plotshape(bearishCandle and ((rsiValue[1] > rsiOB) or (rsiValue > rsiOB)) , color=color.red, style=shape.triangledown, size=size.tiny, location=location.abovebar)

// Two Way Alert generator
alertcondition((bullishCandle and longAlerts) or (bearishCandle and shortAlerts), title="Alert", message="Alert for {{ticker}}")



