Outside Bar + PFR - x Cash Investing
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Phillipowisk

//@version=4
study("x Cash", shorttitle="x Cash Investing", overlay=true)


candle_OutsideBar1 = high > high[1] and low < low[1] and close > open

candle_OutsideBar2 = high > high[1] and low < low[1] and close < open



outsidebar_compra = candle_OutsideBar1 ? color.rgb(63, 231, 231) : na

outsidebar_venda = candle_OutsideBar2 ? color.rgb(240, 62, 195) : na




// plots
barcolor(outsidebar_compra) 

// plots
barcolor(outsidebar_venda) 

// inputs
stoch_length = input(8, "Slow Stoch Length", type=input.integer, minval=2)
stock_smooth = input(3, "Slow Stoch Smooth", type=input.integer, minval=2)
stoch_use = input(false, "Use o filtro para PFR")

stoch_overbought = input(80, "Slow Stoch Overbought", minval=0, type=input.integer)
stoch_oversold = input(20, "Slow Stoch Oversold", minval=0, type=input.integer)




//calcs
stoch_value = sma(stoch(close, high, low, stoch_length), stock_smooth)

candle_bottom = close > close[1] and lowest(2) < lowest(2)[1] and (not stoch_use or stoch_value < stoch_oversold)
candle_top = close < close[1] and highest(2) > highest(2)[1] and (not stoch_use or stoch_value > stoch_overbought)


PFR = candle_bottom ? color.navy : candle_top ? color.yellow : na



// plots
barcolor(PFR)

