Author Message:
The "Bollinger Bands Percentile (BBPct) + STD Channels" mean reversion indicator, developed by Algo_Alert, is a technical analysis tool designed to analyze price positions using Bollinger Bands and Standard Deviation Channels (STDC). The combination of these two indicators reinforces a stronger reversal signal. BBPct calculates the percentile rank of the price's standard deviation relative to a specified lookback period. Standard deviation channels operate by utilizing a moving average as the central line, with upper and lower lines equidistant from the average based on the market's volatility, helping to identify potential price boundaries and deviations.
More details : https://www.tradingview.com/v/Txv4QC95/
CODE:
CSS:
#https://www.tradingview.com/v/Txv4QC95/
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © Algo_Alert
#Bollinger Bands Percentile (BBPct) + STD Channels [Algo Alert]
#indicator(shorttitle="? BBPCT% [Algo Alert]", title="? Bollinger Bands Percent", overlay=false)
# Converted by Sam4Cok@Samer800 - 07/2023
declare lower;
#//Symmetrical Standard Deviation Channels
#//BBPCT
input colorBars = yes;
input BollingerBandLength = 20; # 'Bollinger Band'
input Source = close; # "Source"
input bbMultiplier = 2.0; # "Multiplier"
input showBbStdevHistogram = no; # 'Show Bollinger Band Stdev %'
def na = Double.NaN;
def last = isNaN(close);
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
DefineGlobalColor("up", CreateColor(0,255,187));
DefineGlobalColor("dn", CreateColor(255,0,0));
DefineGlobalColor("histup", CreateColor(38,166,154));
DefineGlobalColor("histdn", CreateColor(178,223,219));
def upper1 = close + 0.05 * close;
def lower1 = close - 0.05 * close;
def stdL = close > lower1;
def stdS = close < upper1;
def basis = Average(Source, BollingerBandLength);
def dev = bbMultiplier * StDev(Source, BollingerBandLength);
def upper = basis + dev;
def lower = basis - dev;
def positionBetweenBands = 100 * (Source - lower) / (upper - lower);
def hist = 100 * dev/close;
def crossUp = (positionBetweenBands Crosses above -8) and stdL;
def crossDn = (positionBetweenBands Crosses Below 108) and stdS;
def upCol = positionBetweenBands > 50;
def upCol1 = positionBetweenBands> 95;
def upCol2 = positionBetweenBands> 110;
def dnCol = positionBetweenBands <= 50;
def dnCol1 = positionBetweenBands<= 25;
def dnCol2 = positionBetweenBands<= 10;
def obupper = if last then na else pos;#if showBbStdev then 1 else pos;
def oblower = if last then na else if showBbStdevHistogram then 0.65 else 110;
def obmid = if last then na else if showBbStdevHistogram then 0.4 else 95;
def osupper = if last then na else if showBbStdevHistogram then 0.1 else 10;
def oslower = if last then na else neg;#then 0 else neg;
def osmid = if last then na else if showBbStdevHistogram then 0.25 else 25;
plot SigUp = if showBbStdevHistogram then na else if crossUp then 5 else -10;
plot SigDn = if showBbStdevHistogram then na else if crossDn then 115 else 130;
SigUp.SetLineWeight(2);
SigDn.SetLineWeight(2);
SigUp.SetDefaultColor(Color.CYAN);
SigDn.SetDefaultColor(Color.MAGENTA);
plot SqUp = if showBbStdevHistogram then if crossUp then hist+0.05 else na else na;
plot SqDn = if showBbStdevHistogram then if crossDn then hist+0.05 else na else na;
SqUp.SetLineWeight(2);
SqDn.SetLineWeight(2);
SqUp.SetPaintingStrategy(PaintingStrategy.SQUARES);
SqDn.SetPaintingStrategy(PaintingStrategy.SQUARES);
SqUp.SetDefaultColor(Color.GREEN);
SqDn.SetDefaultColor(Color.RED);
plot z = if showBbStdevHistogram then na else positionBetweenBands;
z.AssignValueColor(if upCol then GlobalColor("up") else GlobalColor("dn"));
z.SetLineWeight(2);
plot Histo = if showBbStdevHistogram then hist else na;
Histo.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Histo.AssignValueColor( if hist>hist[1] then GlobalColor("histup") else GlobalColor("histdn"));
plot mid = if last or showBbStdevHistogram then na else 50;
mid.SetDefaultColor(Color.GRAY);
mid.SetStyle(Curve.SHORT_DASH);
AssignPriceColor(if !colorBars then Color.CURRENT else if upCol then
if upCol1 then Color.GREEN else Color.DARK_GREEN else
if dnCol1 then Color.RED else Color.DARK_RED);
AddCloud(obupper, oblower, Color.RED);#
AddCloud(oblower, obmid, Color.DARK_RED);
AddCloud(osupper, oslower, Color.GREEN, Color.GREEN, showBbStdevHistogram);
AddCloud(osmid, osupper, Color.DARK_GREEN);
AddCloud(if upCol then z else na, mid, Color.DARK_GREEN);
AddCloud(if upCol1 then z else na, mid, Color.DARK_GREEN);
AddCloud(if upCol2 then z else na, mid, Color.DARK_GREEN);
AddCloud(if dnCol then mid else na, z, Color.DARK_RED);
AddCloud(if dnCol1 then mid else na, z, Color.DARK_RED);
AddCloud(if dnCol2 then mid else na, z, Color.DARK_RED);
#-- END of CODE