Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views2 pages

Message

This document outlines a trading indicator for mean reversion using Bollinger Bands and RSI, designed to identify potential entry and exit signals based on price movements relative to the mean. It includes customizable parameters for Bollinger Bands, RSI levels, and VWAP usage, along with visual signals for trades. Alerts are set for long and short entry signals, as well as exit conditions when the price returns to the mean.

Uploaded by

isaac.iv3n
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Message

This document outlines a trading indicator for mean reversion using Bollinger Bands and RSI, designed to identify potential entry and exit signals based on price movements relative to the mean. It includes customizable parameters for Bollinger Bands, RSI levels, and VWAP usage, along with visual signals for trades. Alerts are set for long and short entry signals, as well as exit conditions when the price returns to the mean.

Uploaded by

isaac.iv3n
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// Mean Reversion with Confirmation Indicator

// This indicator identifies potential mean reversion opportunities with


confirmation signals
// Strategy: Enter when price overextends from mean and shows reversal signals,
exit when price returns to mean

//@version=5
indicator("Mean Reversion with Confirmation", overlay=true)

// Input parameters
bb_length = input.int(20, "Bollinger Band Length", minval=1)
bb_mult = input.float(2.0, "Bollinger Band Multiplier", minval=0.1, step=0.1)
rsi_length = input.int(14, "RSI Length", minval=1)
rsi_oversold = input.int(30, "RSI Oversold Level", minval=1, maxval=100)
rsi_overbought = input.int(70, "RSI Overbought Level", minval=1, maxval=100)
vwap_use = input.bool(true, "Use VWAP")
show_signals = input.bool(true, "Show Entry/Exit Signals")

// Calculate indicators
[bb_middle, bb_upper, bb_lower] = ta.bb(close, bb_length, bb_mult)
rsi = ta.rsi(close, rsi_length)
vwap_value = ta.vwap(close)

// Plot Bollinger Bands


plot(bb_middle, "BB Middle", color.blue)
plot(bb_upper, "BB Upper", color.red)
plot(bb_lower, "BB Lower", color.green)

// Plot VWAP if enabled


plot(vwap_use ? vwap_value : na, "VWAP", color.purple, 2)

// Reversal detection
price_above_upper = close > bb_upper
price_below_lower = close < bb_lower
rsi_overbought_signal = rsi > rsi_overbought
rsi_oversold_signal = rsi < rsi_oversold

// Detect potential entry signals


long_signal = price_below_lower and rsi_oversold_signal and (not vwap_use or close
< vwap_value)
short_signal = price_above_upper and rsi_overbought_signal and (not vwap_use or
close > vwap_value)

// Detect potential exit signals


exit_long = close >= bb_middle
exit_short = close <= bb_middle

// Plot entry signals


plotshape(show_signals and long_signal, "Long Signal", shape.triangleup,
location.belowbar, color.green, size=size.small)
plotshape(show_signals and short_signal, "Short Signal", shape.triangledown,
location.abovebar, color.red, size=size.small)

// Plot exit signals


plotshape(show_signals and exit_long and long_signal[1], "Exit Long", shape.xcross,
location.abovebar, color.green, size=size.tiny)
plotshape(show_signals and exit_short and short_signal[1], "Exit Short",
shape.xcross, location.belowbar, color.red, size=size.tiny)
// Alert conditions
alertcondition(long_signal, "Long Entry Signal", "Price below lower BB with
oversold RSI")
alertcondition(short_signal, "Short Entry Signal", "Price above upper BB with
overbought RSI")
alertcondition(exit_long, "Exit Long Signal", "Price returned to mean")
alertcondition(exit_short, "Exit Short Signal", "Price returned to mean")

// Display indicator values in a table


var table info_table = table.new(position.top_right, 3, 5, color.gray, color.black,
2, color.white, 2)
if (barstate.islast)
table.cell(info_table, 0, 0, "Indicator", bgcolor=color.gray,
text_color=color.white)
table.cell(info_table, 1, 0, "Value", bgcolor=color.gray,
text_color=color.white)
table.cell(info_table, 2, 0, "Signal", bgcolor=color.gray,
text_color=color.white)

table.cell(info_table, 0, 1, "RSI", bgcolor=color.gray, text_color=color.white)


table.cell(info_table, 1, 1, str.tostring(rsi, "#.##"), bgcolor=color.black)
table.cell(info_table, 2, 1, rsi > rsi_overbought ? "Overbought" : rsi <
rsi_oversold ? "Oversold" : "Neutral",
bgcolor=rsi > rsi_overbought ? color.red : rsi < rsi_oversold ?
color.green : color.black)

table.cell(info_table, 0, 2, "BB Position", bgcolor=color.gray,


text_color=color.white)
table.cell(info_table, 1, 2, str.tostring((close - bb_middle) / (bb_upper -
bb_middle), "#.##"), bgcolor=color.black)
table.cell(info_table, 2, 2, close > bb_upper ? "Above Upper" : close <
bb_lower ? "Below Lower" : "Inside Bands",
bgcolor=close > bb_upper ? color.red : close < bb_lower ?
color.green : color.black)

if (vwap_use)
table.cell(info_table, 0, 3, "VWAP", bgcolor=color.gray,
text_color=color.white)
table.cell(info_table, 1, 3, str.tostring(vwap_value, "#.##"),
bgcolor=color.black)
table.cell(info_table, 2, 3, close > vwap_value ? "Above VWAP" : "Below
VWAP",
bgcolor=close > vwap_value ? color.red : color.green)

You might also like