Indicator - Trend Following Setup - Sideways Market Skipper
Indicator - Trend Following Setup - Sideways Market Skipper
0
at https://mozilla.org/MPL/2.0/
// © Arun_K_Bhaskar
//@version=5
indicator(title='Trend Following Setup - Sideways Market Skipper',
shorttitle='Sideways Skip', overlay=false, max_bars_back=500)
tt_r =
"• 'Auto ATR': Automatically sets the range based on the ATR value." +
"\n• The range adjusts automatically when switching between symbols." +
"\n• The default ATR timeframe is 1 hour." +
"\n• For a Supertrend Long Crossover, the range is defined by adding the ATR
value." +
"\n• For a Supertrend Short Crossunder, the range is defined by subtracting the
ATR value." +
"\n\n• Type Points: Manually enter the points for different symbols to define the
volatility range." +
"\n• For example, the points are 60 for NIFTY and 120 for BANKNIFTY."
tt_atr_tf =
"• This uses the ATR value of the given timeframe." +
"\n• The default ATR timeframe is 1 hour."
// Plot Supertrend
upTrend = plot(series=direction < 0 ? supertrend : na, title="Supertrend Up",
color=i_pos_color, style=plot.style_linebr, force_overlay=true)
downTrend = plot(series=direction < 0 ? na : supertrend, title="Supertrend Down",
color=i_neg_color, style=plot.style_linebr, force_overlay=true)
bodyMiddle = plot(series=barstate.isfirst ? na : (open + close) / 2, title="Body
Middle", display=display.none, force_overlay=true)
fill(plot1=bodyMiddle, plot2=upTrend, color=color.new(i_pos_color, 90),
fillgaps=false)
fill(plot1=bodyMiddle, plot2=downTrend, color=color.new(i_neg_color, 90),
fillgaps=false)
// Range Source
range_input = i_atr_range_choice == 'Auto ATR' ? (atr * i_atr_range_multiplier) :
i_atr_range_points
range_source = i_atr_range_choice == 'Type Points' ?
i_atr_range_points :range_input
if ta.change(time('D')) != 0
prev_cum_vol := current_cum_vol
current_cum_vol := volume
else
current_cum_vol += volume
// % Change Filter
bool pchg_above_filter = true
bool pchg_below_filter = true
if i_pchg_filter
pchg_above_filter := cum_pchg > i_pchg_above_below
pchg_below_filter := cum_pchg < -i_pchg_above_below
// ATR Filter
bool atr_filter = true
if i_atr_filter
atr_filter := (high - low) > ta.atr(i_atr_length) * i_atr_multi
// Time Filter
bool time_filter = true
if i_time_filter
time_filter := (hour > i_hour_1 or (hour == i_hour_1 and minute >= i_minute_1))
and (hour < i_hour_2 or (hour == i_hour_2 and minute < i_minute_2))
// Condition 1
short_cont = ta.crossunder(close, supertrend) and barstate.isconfirmed
long_cont = ta.crossover(close, supertrend) and barstate.isconfirmed
if (short_cont)
bottom_price := close - range_source
top_price := na // Reset top_price to avoid plotting it
if (long_cont)
top_price := close + range_source
bottom_price := na // Reset bottom_price to avoid plotting it
// Condition 2
short_break_cond =
close < bottom_price and
open > close and
atr > atr_sma and
pchg_below_filter and
vol_pchg_filter and
atr_filter and
body_filter and
body_size_filter and
volume_filter and
rel_vol_filter and
time_filter and
barstate.isconfirmed
long_break_cond =
close > top_price and
open < close and
atr > atr_sma and
pchg_above_filter and
vol_pchg_filter and
atr_filter and
body_filter and
body_size_filter and
volume_filter and
rel_vol_filter and
time_filter and
barstate.isconfirmed
// Short Signal
var short_current_state = 0
bear_previous_state = nz(short_current_state[1])
short_current_state := bear_previous_state == 2 ? 0 : bear_previous_state
if short_cont and short_current_state == 0
short_current_state := 1
if short_break_cond and short_current_state == 1
short_current_state := 2
// Long Signal
var long_current_state = 0
bull_previous_state = nz(long_current_state[1])
long_current_state := bull_previous_state == 2 ? 0 : bull_previous_state
if long_cont and long_current_state == 0
long_current_state := 1
if long_break_cond and long_current_state == 1
long_current_state := 2
// Color
bgcolor_1 = i_neu_dark_color
bgcolor_2 = i_neu_mid_color
// Plot Table
var table tbl_data = table.new(position=i_tbl_data_pos, columns=2, rows=4,
border_width=1, force_overlay=true)
// Readme First:
//
// Trend Following Setup - Sideways Market Skipper Scanner
//
// Long Signal Logic:
// - Close crosses above the Supertrend.
// - Add ATR value (with multiplier) to the close to identify the potential
sideways or volatility range.
// - When the price crosses this range, it's considered a breakout.
// - The ATR should be rising or the volatility is increasing.
//
// Short Signal Logic:
// - Close crosses below the Supertrend.
// - Substract ATR value (with multiplier) to the close to identify the potential
sideways or volatility range.
// - When the price crosses this range, it's considered a breakdown.
// - The ATR should be rising or the volatility is increasing.
//
// Entry: Enter after the retracement once the signal is generated.