Fukuiz Trend For ThinkOrSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Hello,

is it possible to convert this to a thinkorswim format?
https://www.tradingview.com/script/tTp7kZt4-Fukuiz-Trend/

//@version=5
//Fukuiz
indicator(title='Fukuiz Trend', shorttitle='Fukuiz Trend', format=format.price, precision=2, timeframe='')
//color//
colorwhite = #FFFFFF
colorblue = #6633FF
colorred = #FF3333
colorblue2 = #33CCFF
colorpink = #FF3366
//Fuction//
len = input.int(25, minval=1, title='RSI Short')
len2 = input.int(100, minval=1, title='RSI Long')
src = input(close, 'Source')
up = ta.rma(math.max(ta.change(src), 0), len)
down = ta.rma(-math.min(ta.change(src), 0), len)
up2 = ta.rma(math.max(ta.change(src), 0), len2)
down2 = ta.rma(-math.min(ta.change(src), 0), len2)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - 100 / (1 + up2 / down2)
Bullish = rsi > rsi2
Bearish = rsi < rsi2
Fukuizcolor = Bullish ? color.new(colorblue,0) : Bearish ? color.new(colorred,0) : na
Fukuizcolor2 = Bullish ? color.new(colorblue2,0) : Bearish ? color.new(colorpink,0) : na
Fukuizcolor3 = Bullish ? color.new(colorblue,75) : Bearish ? color.new(colorred,75) : na
//Plot//
l1 = plot(rsi, 'RSI Short', color=Fukuizcolor, linewidth=2, style=plot.style_line)
l2 = plot(rsi2, 'RSI Long', color=Fukuizcolor2, linewidth=2, style=plot.style_line)
band2 = hline(50, 'Middle Band', color=#FFCC99)
band1 = hline(70, 'Upper Band', color=#FFCC99)
band0 = hline(30, 'Lower Band', color=#FFCC99)
fill(band1, band0, color.new(#0946CA, 90), title='Background')
fill(l1, l2, color=Fukuizcolor3, title='Trend Background')

//DIVERGENCE//
lbR = input(title='Pivot Lookback Right', defval=5)
lbL = input(title='Pivot Lookback Left', defval=5)
rangeUpper = input(title='Max of Lookback Range', defval=60)
rangeLower = input(title='Min of Lookback Range', defval=5)
plotBull = input(title='Bullish Divergence', defval=false)
plotBear = input(title='Bearish Divergence', defval=false)
bearColor = color.red
bullColor = color.green
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
noneColor = color.new(color.white, 100)
osc = ta.rsi(src, len)
plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true
phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
oscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
priceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1)
bullCond = plotBull and priceLL and oscHL and plFound
plot(plFound ? osc[lbR] : na, offset=-lbR, title='Bullish Divergence Line', linewidth=2, color=bullCond ? bullColor : noneColor,display=display.none)
plotshape(bullCond ? osc[lbR] : na, offset=-lbR, title='Bullish Divergence Label', text=' Bull ', style=shape.labelup, location=location.absolute, color=color.new(bullColor, 0), textcolor=color.new(textColor, 0))
oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1)
bearCond = plotBear and priceHH and oscLH and phFound
plot(phFound ? osc[lbR] : na, offset=-lbR, title='Bearish Divergence Line', linewidth=2, color=bearCond ? bearColor : noneColor,display=display.none)
plotshape(bearCond ? osc[lbR] : na, offset=-lbR, title='Bearish Divergence Label', text=' Bear ', style=shape.labeldown, location=location.absolute, color=color.new(bearColor, 0), textcolor=color.new(textColor, 0))
find below

CSS:
# https://www.tradingview.com/v/tTp7kZt4/
#//Fukuiz
#indicator(title='Fukuiz Trend', shorttitle='Fukuiz Trend', format=format.price, precision=2, timeframe='')
# Converted by Sam4Cok@Samer800 - 02/2023 - request from UseThinkScript.com member
declare lower;

#//Fuction//
input Overbought = 70;
input Oversold = 30;
input len = 25;#, minval=1, title='RSI Short')
input len2 = 100;#, minval=1, title='RSI Long')
input src = close;#, 'Source')

def na = Double.NaN;
def last = isNaN(close[1]);
# --- Colors
DefineGlobalColor("colorwhite" , Color.WHITE);
DefineGlobalColor("colorblue" , CreateColor(102,51,255));
DefineGlobalColor("colorred" , CreateColor(255,51,51));
DefineGlobalColor("colorblue2" , CreateColor(51,204,255));
DefineGlobalColor("colorpink"  , CreateColor(255, 51, 102));

def change = src-src[1];
def up = WildersAverage(max(change, 0), len);
def down = WildersAverage(-min(change, 0), len);
def up2 = WildersAverage(max(change, 0), len2);
def down2 = WildersAverage(-min(change, 0), len2);
def rsi  = if down == 0 then 100 else if up == 0 then 0 else 100 - 100 / (1 + up / down);
def rsi2 = if down2 == 0 then 100 else if up2 == 0 then 0 else 100 - 100 / (1 + up2 / down2);

def Bullish = rsi > rsi2;
def Bearish = rsi < rsi2;
def Fukuizcolor = if Bullish then 1 else if Bearish then -1 else 0;
#def Fukuizcolor2 = Bullish ? color.new(colorblue2,0) : Bearish ? color.new(colorpink,0) : na
#def Fukuizcolor3 = Bullish ? color.new(colorblue,75) : Bearish ? color.new(colorred,75) : na

#//Plot//
plot l1 = rsi;#, 'RSI Short', color=Fukuizcolor, linewidth=2, style=plot.style_line)
l1.SetLineWeight(2);
l1.AssignValueColor(if Fukuizcolor>0 then GlobalColor("colorblue") else
                    if Fukuizcolor<0 then GlobalColor("colorred") else Color.GRAY);
plot l2 = rsi2;#, 'RSI Long', color=Fukuizcolor2, linewidth=2, style=plot.style_line)
l2.SetLineWeight(2);
l2.AssignValueColor(if Fukuizcolor>0 then GlobalColor("colorblue") else
                    if Fukuizcolor<0 then GlobalColor("colorred") else Color.GRAY);

plot band2 = if last then na else (Overbought + Oversold)/2;#, 'Middle Band', color=#FFCC99)
band2.SetDefaultColor(Color.GRAY);
band2.SetStyle(Curve.SHORT_DASH);
plot band1 = if last then na else Overbought;#, 'Upper Band', color=#FFCC99)
band1.SetDefaultColor(Color.GRAY);
plot band0 = if last then na else Oversold;#, 'Lower Band', color=#FFCC99)
band0.SetDefaultColor(Color.GRAY);


AddCloud(band1, band0, CreateColor(48, 6, 80));#new(#0946CA, 90), title='Background')
AddCloud(l1, l2, GlobalColor("colorblue"), GlobalColor("colorred"));#color=Fukuizcolor3, title='Trend Background')

#----Div-----------
input LookBackRight  = 5;           # "Pivot Lookback Right"
input LookBackLeft  = 5;           # "Pivot Lookback Left"
input MaxLookback = 60;   # "Max of Lookback Range"
input MinLookback = 5;    # "Min of Lookback Range"
input DivBull = yes;      # "Plot Bullish"
input DivHiddenBull = no; # "Plot Hidden Bullish"
input DivBear = yes;      # "Plot Bearish"
input DivHiddenBear = no; # "Plot Hidden Bearish"
def divSrc = RSI;

def h = high;
def l = low;

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL+1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL+1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
#valuewhen (Cond, source, lbr, occurrence)
script valuewhen {
  input cond = 0;
  input src = close;
  input MinLookback = 5;
  input MaxLookback = 60;
  input occurrence = 0;
  def n = occurrence + 1;
  def offset = fold j = MinLookback to MaxLookback + 1 with p=1 while p < n + 1
    do p + ( if p == n then j - n else if cond[j]==yes then 1 else 0 );
  plot price = GetValue(src, offset-1);
}
#_inRange(cond) =>
script _inRange {
    input cond = yes;
    input rangeUpper = 60;
    input rangeLower = 5;
        def bars = if cond then 0 else bars[1] + 1;
        def inrange =  (rangeLower <= bars) and (bars <= rangeUpper);
plot retrun = inRange;
}
def pl = findpivots(divSrc,-1, LookBackLeft, LookBackRight);
def ph = findpivots(divSrc, 1, LookBackLeft, LookBackRight);

def plFound = if !isNaN(pl) then 1 else 0;
def phFound = if !isNaN(ph) then 1 else 0;

def vlFound = valuewhen(plFound, divSrc, MinLookback, MaxLookback, 1);
def vhFound = valuewhen(phFound, divSrc, MinLookback, MaxLookback, 1);

def plPrice = valuewhen(plFound, l, MinLookback, MaxLookback, 1);
def phPrice = valuewhen(phFound, h, MinLookback, MaxLookback, 1);

#// Regular Bullish
def oscHL = divSrc > vlFound and  _inRange(plFound[1],MaxLookback,MinLookback);
def priceLL = l < plPrice;
def bullCond = DivBull and plFound and oscHL and priceLL;
#// Hidden Bullish
def oscLL = divSrc < vlFound and  _inRange(plFound[1],MaxLookback,MinLookback);
def priceHL = l > plPrice;
def hiddenBullCond = DivHiddenBull and plFound and oscLL and priceHL;

#// Regular Bearish
def oscLH   = divSrc < vhFound and  _inRange(phFound[1],MaxLookback,MinLookback);
def priceHH = h > phPrice;
def bearCond = DivBear and phFound and oscLH and priceHH;
#// Hidden Bearish
def oscHH = divSrc > vhFound and  _inRange(phFound[1],MaxLookback,MinLookback);
def priceLH = h < phPrice;
def hiddenBearCond = DivHiddenBear and phFound and oscHH and priceLH;

#------ Bubbles
addchartbubble(bullCond, divSrc, "R", color.GREEN, no);
addchartbubble(bearCond, divSrc, "R", CreateColor(156,39,176), yes);
addchartbubble(hiddenBullCond, divSrc, "H", color.DARK_green, no);
addchartbubble(hiddenBearCond, divSrc, "H", color.DARK_red, yes);

#--- END CODE
 
Looks like a good one.
https://www.tradingview.com/script/tTp7kZt4-Fukuiz-Trend/

IjWSGZq.png
 
find below

CSS:
# https://www.tradingview.com/v/tTp7kZt4/
#//Fukuiz
#indicator(title='Fukuiz Trend', shorttitle='Fukuiz Trend', format=format.price, precision=2, timeframe='')
# Converted by Sam4Cok@Samer800 - 02/2023 - request from UseThinkScript.com member
declare lower;

#//Fuction//
input Overbought = 70;
input Oversold = 30;
input len = 25;#, minval=1, title='RSI Short')
input len2 = 100;#, minval=1, title='RSI Long')
input src = close;#, 'Source')

def na = Double.NaN;
def last = isNaN(close[1]);
# --- Colors
DefineGlobalColor("colorwhite" , Color.WHITE);
DefineGlobalColor("colorblue" , CreateColor(102,51,255));
DefineGlobalColor("colorred" , CreateColor(255,51,51));
DefineGlobalColor("colorblue2" , CreateColor(51,204,255));
DefineGlobalColor("colorpink"  , CreateColor(255, 51, 102));

def change = src-src[1];
def up = WildersAverage(max(change, 0), len);
def down = WildersAverage(-min(change, 0), len);
def up2 = WildersAverage(max(change, 0), len2);
def down2 = WildersAverage(-min(change, 0), len2);
def rsi  = if down == 0 then 100 else if up == 0 then 0 else 100 - 100 / (1 + up / down);
def rsi2 = if down2 == 0 then 100 else if up2 == 0 then 0 else 100 - 100 / (1 + up2 / down2);

def Bullish = rsi > rsi2;
def Bearish = rsi < rsi2;
def Fukuizcolor = if Bullish then 1 else if Bearish then -1 else 0;
#def Fukuizcolor2 = Bullish ? color.new(colorblue2,0) : Bearish ? color.new(colorpink,0) : na
#def Fukuizcolor3 = Bullish ? color.new(colorblue,75) : Bearish ? color.new(colorred,75) : na

#//Plot//
plot l1 = rsi;#, 'RSI Short', color=Fukuizcolor, linewidth=2, style=plot.style_line)
l1.SetLineWeight(2);
l1.AssignValueColor(if Fukuizcolor>0 then GlobalColor("colorblue") else
                    if Fukuizcolor<0 then GlobalColor("colorred") else Color.GRAY);
plot l2 = rsi2;#, 'RSI Long', color=Fukuizcolor2, linewidth=2, style=plot.style_line)
l2.SetLineWeight(2);
l2.AssignValueColor(if Fukuizcolor>0 then GlobalColor("colorblue") else
                    if Fukuizcolor<0 then GlobalColor("colorred") else Color.GRAY);

plot band2 = if last then na else (Overbought + Oversold)/2;#, 'Middle Band', color=#FFCC99)
band2.SetDefaultColor(Color.GRAY);
band2.SetStyle(Curve.SHORT_DASH);
plot band1 = if last then na else Overbought;#, 'Upper Band', color=#FFCC99)
band1.SetDefaultColor(Color.GRAY);
plot band0 = if last then na else Oversold;#, 'Lower Band', color=#FFCC99)
band0.SetDefaultColor(Color.GRAY);


AddCloud(band1, band0, CreateColor(48, 6, 80));#new(#0946CA, 90), title='Background')
AddCloud(l1, l2, GlobalColor("colorblue"), GlobalColor("colorred"));#color=Fukuizcolor3, title='Trend Background')

#----Div-----------
input LookBackRight  = 5;           # "Pivot Lookback Right"
input LookBackLeft  = 5;           # "Pivot Lookback Left"
input MaxLookback = 60;   # "Max of Lookback Range"
input MinLookback = 5;    # "Min of Lookback Range"
input DivBull = yes;      # "Plot Bullish"
input DivHiddenBull = no; # "Plot Hidden Bullish"
input DivBear = yes;      # "Plot Bearish"
input DivHiddenBear = no; # "Plot Hidden Bearish"
def divSrc = RSI;

def h = high;
def l = low;

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL+1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL+1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
#valuewhen (Cond, source, lbr, occurrence)
script valuewhen {
  input cond = 0;
  input src = close;
  input MinLookback = 5;
  input MaxLookback = 60;
  input occurrence = 0;
  def n = occurrence + 1;
  def offset = fold j = MinLookback to MaxLookback + 1 with p=1 while p < n + 1
    do p + ( if p == n then j - n else if cond[j]==yes then 1 else 0 );
  plot price = GetValue(src, offset-1);
}
#_inRange(cond) =>
script _inRange {
    input cond = yes;
    input rangeUpper = 60;
    input rangeLower = 5;
        def bars = if cond then 0 else bars[1] + 1;
        def inrange =  (rangeLower <= bars) and (bars <= rangeUpper);
plot retrun = inRange;
}
def pl = findpivots(divSrc,-1, LookBackLeft, LookBackRight);
def ph = findpivots(divSrc, 1, LookBackLeft, LookBackRight);

def plFound = if !isNaN(pl) then 1 else 0;
def phFound = if !isNaN(ph) then 1 else 0;

def vlFound = valuewhen(plFound, divSrc, MinLookback, MaxLookback, 1);
def vhFound = valuewhen(phFound, divSrc, MinLookback, MaxLookback, 1);

def plPrice = valuewhen(plFound, l, MinLookback, MaxLookback, 1);
def phPrice = valuewhen(phFound, h, MinLookback, MaxLookback, 1);

#// Regular Bullish
def oscHL = divSrc > vlFound and  _inRange(plFound[1],MaxLookback,MinLookback);
def priceLL = l < plPrice;
def bullCond = DivBull and plFound and oscHL and priceLL;
#// Hidden Bullish
def oscLL = divSrc < vlFound and  _inRange(plFound[1],MaxLookback,MinLookback);
def priceHL = l > plPrice;
def hiddenBullCond = DivHiddenBull and plFound and oscLL and priceHL;

#// Regular Bearish
def oscLH   = divSrc < vhFound and  _inRange(phFound[1],MaxLookback,MinLookback);
def priceHH = h > phPrice;
def bearCond = DivBear and phFound and oscLH and priceHH;
#// Hidden Bearish
def oscHH = divSrc > vhFound and  _inRange(phFound[1],MaxLookback,MinLookback);
def priceLH = h < phPrice;
def hiddenBearCond = DivHiddenBear and phFound and oscHH and priceLH;

#------ Bubbles
addchartbubble(bullCond, divSrc, "R", color.GREEN, no);
addchartbubble(bearCond, divSrc, "R", CreateColor(156,39,176), yes);
addchartbubble(hiddenBullCond, divSrc, "H", color.DARK_green, no);
addchartbubble(hiddenBearCond, divSrc, "H", color.DARK_red, yes);

#--- END CODE
Big up
 
find below

CSS:
# https://www.tradingview.com/v/tTp7kZt4/
#//Fukuiz
#indicator(title='Fukuiz Trend', shorttitle='Fukuiz Trend', format=format.price, precision=2, timeframe='')
# Converted by Sam4Cok@Samer800 - 02/2023 - request from UseThinkScript.com member
declare lower;

#//Fuction//
input Overbought = 70;
input Oversold = 30;
input len = 25;#, minval=1, title='RSI Short')
input len2 = 100;#, minval=1, title='RSI Long')
input src = close;#, 'Source')

def na = Double.NaN;
def last = isNaN(close[1]);
# --- Colors
DefineGlobalColor("colorwhite" , Color.WHITE);
DefineGlobalColor("colorblue" , CreateColor(102,51,255));
DefineGlobalColor("colorred" , CreateColor(255,51,51));
DefineGlobalColor("colorblue2" , CreateColor(51,204,255));
DefineGlobalColor("colorpink"  , CreateColor(255, 51, 102));

def change = src-src[1];
def up = WildersAverage(max(change, 0), len);
def down = WildersAverage(-min(change, 0), len);
def up2 = WildersAverage(max(change, 0), len2);
def down2 = WildersAverage(-min(change, 0), len2);
def rsi  = if down == 0 then 100 else if up == 0 then 0 else 100 - 100 / (1 + up / down);
def rsi2 = if down2 == 0 then 100 else if up2 == 0 then 0 else 100 - 100 / (1 + up2 / down2);

def Bullish = rsi > rsi2;
def Bearish = rsi < rsi2;
def Fukuizcolor = if Bullish then 1 else if Bearish then -1 else 0;
#def Fukuizcolor2 = Bullish ? color.new(colorblue2,0) : Bearish ? color.new(colorpink,0) : na
#def Fukuizcolor3 = Bullish ? color.new(colorblue,75) : Bearish ? color.new(colorred,75) : na

#//Plot//
plot l1 = rsi;#, 'RSI Short', color=Fukuizcolor, linewidth=2, style=plot.style_line)
l1.SetLineWeight(2);
l1.AssignValueColor(if Fukuizcolor>0 then GlobalColor("colorblue") else
                    if Fukuizcolor<0 then GlobalColor("colorred") else Color.GRAY);
plot l2 = rsi2;#, 'RSI Long', color=Fukuizcolor2, linewidth=2, style=plot.style_line)
l2.SetLineWeight(2);
l2.AssignValueColor(if Fukuizcolor>0 then GlobalColor("colorblue") else
                    if Fukuizcolor<0 then GlobalColor("colorred") else Color.GRAY);

plot band2 = if last then na else (Overbought + Oversold)/2;#, 'Middle Band', color=#FFCC99)
band2.SetDefaultColor(Color.GRAY);
band2.SetStyle(Curve.SHORT_DASH);
plot band1 = if last then na else Overbought;#, 'Upper Band', color=#FFCC99)
band1.SetDefaultColor(Color.GRAY);
plot band0 = if last then na else Oversold;#, 'Lower Band', color=#FFCC99)
band0.SetDefaultColor(Color.GRAY);


AddCloud(band1, band0, CreateColor(48, 6, 80));#new(#0946CA, 90), title='Background')
AddCloud(l1, l2, GlobalColor("colorblue"), GlobalColor("colorred"));#color=Fukuizcolor3, title='Trend Background')

#----Div-----------
input LookBackRight  = 5;           # "Pivot Lookback Right"
input LookBackLeft  = 5;           # "Pivot Lookback Left"
input MaxLookback = 60;   # "Max of Lookback Range"
input MinLookback = 5;    # "Min of Lookback Range"
input DivBull = yes;      # "Plot Bullish"
input DivHiddenBull = no; # "Plot Hidden Bullish"
input DivBear = yes;      # "Plot Bearish"
input DivHiddenBear = no; # "Plot Hidden Bearish"
def divSrc = RSI;

def h = high;
def l = low;

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL+1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL+1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
#valuewhen (Cond, source, lbr, occurrence)
script valuewhen {
  input cond = 0;
  input src = close;
  input MinLookback = 5;
  input MaxLookback = 60;
  input occurrence = 0;
  def n = occurrence + 1;
  def offset = fold j = MinLookback to MaxLookback + 1 with p=1 while p < n + 1
    do p + ( if p == n then j - n else if cond[j]==yes then 1 else 0 );
  plot price = GetValue(src, offset-1);
}
#_inRange(cond) =>
script _inRange {
    input cond = yes;
    input rangeUpper = 60;
    input rangeLower = 5;
        def bars = if cond then 0 else bars[1] + 1;
        def inrange =  (rangeLower <= bars) and (bars <= rangeUpper);
plot retrun = inRange;
}
def pl = findpivots(divSrc,-1, LookBackLeft, LookBackRight);
def ph = findpivots(divSrc, 1, LookBackLeft, LookBackRight);

def plFound = if !isNaN(pl) then 1 else 0;
def phFound = if !isNaN(ph) then 1 else 0;

def vlFound = valuewhen(plFound, divSrc, MinLookback, MaxLookback, 1);
def vhFound = valuewhen(phFound, divSrc, MinLookback, MaxLookback, 1);

def plPrice = valuewhen(plFound, l, MinLookback, MaxLookback, 1);
def phPrice = valuewhen(phFound, h, MinLookback, MaxLookback, 1);

#// Regular Bullish
def oscHL = divSrc > vlFound and  _inRange(plFound[1],MaxLookback,MinLookback);
def priceLL = l < plPrice;
def bullCond = DivBull and plFound and oscHL and priceLL;
#// Hidden Bullish
def oscLL = divSrc < vlFound and  _inRange(plFound[1],MaxLookback,MinLookback);
def priceHL = l > plPrice;
def hiddenBullCond = DivHiddenBull and plFound and oscLL and priceHL;

#// Regular Bearish
def oscLH   = divSrc < vhFound and  _inRange(phFound[1],MaxLookback,MinLookback);
def priceHH = h > phPrice;
def bearCond = DivBear and phFound and oscLH and priceHH;
#// Hidden Bearish
def oscHH = divSrc > vhFound and  _inRange(phFound[1],MaxLookback,MinLookback);
def priceLH = h < phPrice;
def hiddenBearCond = DivHiddenBear and phFound and oscHH and priceLH;

#------ Bubbles
addchartbubble(bullCond, divSrc, "R", color.GREEN, no);
addchartbubble(bearCond, divSrc, "R", CreateColor(156,39,176), yes);
addchartbubble(hiddenBullCond, divSrc, "H", color.DARK_green, no);
addchartbubble(hiddenBearCond, divSrc, "H", color.DARK_red, yes);

#--- END CODE
Can someone please make an upper study for just the bubbles ? Please
 
Those red and green "R" are pretty accurate when they do show up. :unsure: Probably too good to be true.
 
Those red and green "R" are pretty accurate when they do show up. :unsure: Probably too good to be true.
Was the TradingView Script a conversion from thinkorswim? In the code it says # Converted by Sam4Cok@Samer800 - 02/2023 - request from UseThinkScript.com member
 
Trading view has an option to select multi time frame ..can anyone add that option please ?
try below
CSS:
# https://www.tradingview.com/v/tTp7kZt4/
#//Fukuiz
#indicator(title='Fukuiz Trend', shorttitle='Fukuiz Trend', format=format.price, precision=2, timeframe='')
# Converted by Sam4Cok@Samer800 - 02/2023 - request from UseThinkScript.com member
#--- Update - added MTF option - 05/2023
declare lower;

#//Fuction//
input Overbought = 65;
input Oversold = 35;
input OscSrc   = {default RSI, CCI, MFI, CMO, RVI, VPN};
input len = 25;#, minval=1, title='RSI Short')
input len2 = 100;#, minval=1, title='RSI Long')
input Source = close;#, 'Source')
input useChartTimeframe = {default "Yes", "No"};
input ManualTimeframe = AggregationPeriod.FIFTEEN_MIN;

def src;
def h;
def l;
def v;
switch (useChartTimeframe) {
case "Yes":
    src = Source;
    h   = high;
    l   = low;
    v   = volume;
case "No":
    src = close(Period = ManualTimeframe);
    h   = high(Period = ManualTimeframe);
    l   = low(Period = ManualTimeframe);
    v   = volume(Period = ManualTimeframe);
}

def na = Double.NaN;
def last = IsNaN(close[1]);

Script RVI {
input h = high;
input l = low;
input averageLength = 14;
input stDevLength = 10;
input averageType = AverageType.EXPONENTIAL;

def stDevHi = stDev(h, stDevLength);
def stDevLo = stDev(l, stDevLength);
def avgStDevHiUp = MovingAverage(averageType, if h > h[1] then stDevHi else 0, averageLength);
def avgStDevHiDown = MovingAverage(averageType, if h < h[1] then stDevHi else 0, averageLength);
def avgStDevLoUp = MovingAverage(averageType, if l > l[1] then stDevLo else 0, averageLength);
def avgStDevLoDown = MovingAverage(averageType, if l < l[1] then stDevLo else 0, averageLength);
def rviHi = if avgStDevHiUp + avgStDevHiDown == 0 then 50 else 100 * avgStDevHiUp / (avgStDevHiUp + avgStDevHiDown);
def rviLo = if avgStDevLoUp + avgStDevLoDown == 0 then 50 else 100 * avgStDevLoUp / (avgStDevLoUp + avgStDevLoDown);
plot RVI = (rviHi + rviLo) / 2;
}

script VPN {
input h = high;
input c = close;
input l = low;
input v = volume;
input length = 30;
input emaLength = 3;
input averageLength = 30;
input factor = 0.1;
input criticalValue = 10;
input averageType = AverageType.SIMPLE;
def hlc = (h + c + l)/3;
def tr = TrueRange(h, c, l);
def atr = WildersAverage(tr, length);
def diff = hlc - hlc[1];
def vp = Sum(if diff > factor * atr then v else 0, length);
def vn = Sum(if diff < -factor * atr then v else 0, length);
plot VPN = ExpAverage(100 * (vp - vn) / Sum(v, length), emaLength);
}
script CCI {
    input hi = high;
    input cl = close;
    input lo = low;
    input length = 14;
    def price = cl + lo + hi;
    def linDev = LinDev(price, length);
    plot CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
}
script CMO {
    input curClose = close;
    input length = 20;
    def prevClose = curClose[1];
    def inc = if curClose > prevClose then curClose - prevClose else 0;
    def dec = if prevClose > curClose then prevClose - curClose else 0;
    def sumInc = Sum(inc, length);
    def sumDec = Sum(dec, length);
    plot CMO = if sumInc + sumDec == 0 then 0 else (sumInc - sumDec) / (sumInc + sumDec) * 100;
}
#normalize(series float src, float min, float max) =>
script normalize {
    input src = close;
    input min = 0;
    input max = 100;
    def _historicMin1 =  100000000000;
    def _historicMax1 =  0.00000000001;
    def _historicMin = Min(src, Min(_historicMin[1], _historicMin1));
    def _historicMax = Max(src, Max(_historicMax[1], _historicMax1));
    def normalize = min + (max - min) * (src - _historicMin) / Max(_historicMax - _historicMin, 0.00000000001);
    plot out = normalize;
}
#rescale(series float src, float oldMin, float oldMax, float newMin, float newMax) =>
script rescale {
    input src = close;
    input oldMin = -100;
    input oldMax = 100;
    input newMin = 0;
    input newMax = 100;
    def rescale = newMin + (newMax - newMin) * (src - oldMin) / Max(oldMax - oldMin, 0.00000000001);
    plot out = rescale;
}
# --- Colors
DefineGlobalColor("colorwhite" , Color.WHITE);
DefineGlobalColor("colorblue"  , CreateColor(102, 51, 255));
DefineGlobalColor("colorred"   , CreateColor(255, 51, 51));
DefineGlobalColor("colorblue2" , CreateColor(51, 204, 255));
DefineGlobalColor("colorpink"  , CreateColor(255, 51, 102));
def nRSI1 = RSI(PRICE = src, LENGTH = len);
def nRSI2 = RSI(PRICE = src, LENGTH = len2);
def RSI = rescale(ExpAverage(nRSI1, 3), 0, 100, 0, 100);
def RSI2 = rescale(ExpAverage(nRSI2, 3), 0, 100, 0, 100);
#-- CMO--
def nCMO1 = CMO(src, len);
def nCMO2 = CMO(src, len2);
def cmo  = rescale(ExpAverage(nCMO1, 3), -100, 100, 0, 100);
def cmo2 =  rescale(ExpAverage(nCMO2, 3), -100, 100, 0, 100);
#--CCI
def nCCI1 = CCI(h, src, l, len);
def nCCI2 = CCI(h, src, l, len2);
def CCI = normalize(ExpAverage(nCCI1, 3), 0, 100);
def CCI2 = normalize(ExpAverage(nCCI2, 3), 0, 100);
#-- RVI
def nRVI1 = RVI(h, l ,len);
def nRVI2 = RVI(h, l, len2);
def rvi = rescale(ExpAverage(nRVI1, 3), 0, 100, 0, 100);
def rvi2 = rescale(ExpAverage(nRVI2, 3), 0, 100, 0, 100);
#-- VPN
def nVPN1 = VPN(h, src, l, v, len);
def nVPN2 = VPN(h, src, l, v, len2);
def vpn  = rescale(ExpAverage(nVPN1, 3), -50, 50, 0, 100);
def vpn2 =  rescale(ExpAverage(nVPN2, 3), -50, 50, 0, 100);
#-- MF
def MoneyFlow1 = Sum(if src < src[1] then -src * v else if src > src[1] then src * v else 0, len);
def MoneyFlow2 = Sum(if src < src[1] then -src * v else if src > src[1] then src * v else 0, len2);
def MF = Average(MoneyFlow1, 1);
def mf2 = Average(MoneyFlow2, 1);

def osc = if OscSrc == OscSrc.RSI then RSI else
          if OscSrc == OscSrc.MFI then MF else
          if OscSrc == OscSrc.CCI then CCI else
          if OscSrc == OscSrc.RVI then rvi else
          if OscSrc == OscSrc.CMO then cmo else vpn;

def osc2 = if OscSrc == OscSrc.RSI then RSI2 else
           if OscSrc == OscSrc.MFI then mf2 else
           if OscSrc == OscSrc.CCI then CCI2 else
           if OscSrc == OscSrc.RVI then rvi2 else
           if OscSrc == OscSrc.CMO then cmo2 else vpn2;

def Bullish = osc > osc2;
def Bearish = osc < osc2;
def Fukuizcolor = if Bullish then 1 else if Bearish then -1 else 0;

#//Plot//
plot l1 = osc;#, 'RSI Short', color=Fukuizcolor, linewidth=2, style=plot.style_line)
l1.SetLineWeight(2);
l1.AssignValueColor(if Fukuizcolor > 0 then GlobalColor("colorblue") else
                    if Fukuizcolor < 0 then GlobalColor("colorred") else Color.GRAY);
plot l2 = osc2;#, 'RSI Long', color=Fukuizcolor2, linewidth=2, style=plot.style_line)
l2.SetLineWeight(2);
l2.AssignValueColor(if Fukuizcolor > 0 then GlobalColor("colorblue") else
                    if Fukuizcolor < 0 then GlobalColor("colorred") else Color.GRAY);

plot band2 = if last then na else (Overbought + Oversold) / 2;#, 'Middle Band', color=#FFCC99)
band2.SetDefaultColor(Color.GRAY);
band2.SetStyle(Curve.SHORT_DASH);
plot band1 = if last then na else Overbought;#, 'Upper Band', color=#FFCC99)
band1.SetDefaultColor(Color.GRAY);
plot band0 = if last then na else Oversold;#, 'Lower Band', color=#FFCC99)
band0.SetDefaultColor(Color.GRAY);


AddCloud(band1, band0, CreateColor(48, 6, 80));#new(#0946CA, 90), title='Background')
AddCloud(l1, l2, GlobalColor("colorblue"), GlobalColor("colorred"));#color=Fukuizcolor3, title='Trend Background')

#----Div-----------
input LookBackRight  = 5;           # "Pivot Lookback Right"
input LookBackLeft  = 5;           # "Pivot Lookback Left"
input MaxLookback = 60;   # "Max of Lookback Range"
input MinLookback = 5;    # "Min of Lookback Range"
input DivBull = yes;      # "Plot Bullish"
input DivHiddenBull = no; # "Plot Hidden Bullish"
input DivBear = yes;      # "Plot Bearish"
input DivHiddenBear = no; # "Plot Hidden Bearish"
def divSrc = osc;

#def h = high;
#def l = low;

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
    if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
#valuewhen (Cond, source, lbr, occurrence)
script valuewhen {
    input cond = 0;
    input src = close;
    input MinLookback = 5;
    input MaxLookback = 60;
    input occurrence = 0;
    def n = occurrence + 1;
    def offset = fold j = MinLookback to MaxLookback + 1 with p=1 while p < n + 1
    do p + ( if p == n then j - n else if cond[j] == yes then 1 else 0 );
    plot price = GetValue(src, offset - 1);
}
#_inRange(cond) =>
script _inRange {
    input cond = yes;
    input rangeUpper = 60;
    input rangeLower = 5;
    def bars = if cond then 0 else bars[1] + 1;
    def inrange =  (rangeLower <= bars) and (bars <= rangeUpper);
    plot retrun = inrange;
}
def pl = findpivots(divSrc, -1, LookBackLeft, LookBackRight);
def ph = findpivots(divSrc, 1, LookBackLeft, LookBackRight);

def plFound = if !IsNaN(pl) then 1 else 0;
def phFound = if !IsNaN(ph) then 1 else 0;

def vlFound = valuewhen(plFound, divSrc, MinLookback, MaxLookback, 1);
def vhFound = valuewhen(phFound, divSrc, MinLookback, MaxLookback, 1);

def plPrice = valuewhen(plFound, l, MinLookback, MaxLookback, 1);
def phPrice = valuewhen(phFound, h, MinLookback, MaxLookback, 1);

#// Regular Bullish
def oscHL = divSrc > vlFound and  _inRange(plFound[1], MaxLookback, MinLookback);
def priceLL = l < plPrice;
def bullCond = DivBull and plFound and oscHL and priceLL;
#// Hidden Bullish
def oscLL = divSrc < vlFound and  _inRange(plFound[1], MaxLookback, MinLookback);
def priceHL = l > plPrice;
def hiddenBullCond = DivHiddenBull and plFound and oscLL and priceHL;

#// Regular Bearish
def oscLH   = divSrc < vhFound and  _inRange(phFound[1], MaxLookback, MinLookback);
def priceHH = h > phPrice;
def bearCond = DivBear and phFound and oscLH and priceHH;
#// Hidden Bearish
def oscHH = divSrc > vhFound and  _inRange(phFound[1], MaxLookback, MinLookback);
def priceLH = h < phPrice;
def hiddenBearCond = DivHiddenBear and phFound and oscHH and priceLH;

#------ Bubbles
AddChartBubble(bullCond, divSrc, "R", Color.GREEN, no);
AddChartBubble(bearCond, divSrc, "R", CreateColor(156, 39, 176), yes);
AddChartBubble(hiddenBullCond, divSrc, "H", Color.DARK_GREEN, no);
AddChartBubble(hiddenBearCond, divSrc, "H", Color.DARK_RED, yes);

#--- END CODE
 
try below
CSS:
# https://www.tradingview.com/v/tTp7kZt4/
#//Fukuiz
#indicator(title='Fukuiz Trend', shorttitle='Fukuiz Trend', format=format.price, precision=2, timeframe='')
# Converted by Sam4Cok@Samer800 - 02/2023 - request from UseThinkScript.com member
#--- Update - added MTF option - 05/2023
declare lower;

#//Fuction//
input Overbought = 65;
input Oversold = 35;
input OscSrc   = {default RSI, CCI, MFI, CMO, RVI, VPN};
input len = 25;#, minval=1, title='RSI Short')
input len2 = 100;#, minval=1, title='RSI Long')
input Source = close;#, 'Source')
input useChartTimeframe = {default "Yes", "No"};
input ManualTimeframe = AggregationPeriod.FIFTEEN_MIN;

def src;
def h;
def l;
def v;
switch (useChartTimeframe) {
case "Yes":
    src = Source;
    h   = high;
    l   = low;
    v   = volume;
case "No":
    src = close(Period = ManualTimeframe);
    h   = high(Period = ManualTimeframe);
    l   = low(Period = ManualTimeframe);
    v   = volume(Period = ManualTimeframe);
}

def na = Double.NaN;
def last = IsNaN(close[1]);

Script RVI {
input h = high;
input l = low;
input averageLength = 14;
input stDevLength = 10;
input averageType = AverageType.EXPONENTIAL;

def stDevHi = stDev(h, stDevLength);
def stDevLo = stDev(l, stDevLength);
def avgStDevHiUp = MovingAverage(averageType, if h > h[1] then stDevHi else 0, averageLength);
def avgStDevHiDown = MovingAverage(averageType, if h < h[1] then stDevHi else 0, averageLength);
def avgStDevLoUp = MovingAverage(averageType, if l > l[1] then stDevLo else 0, averageLength);
def avgStDevLoDown = MovingAverage(averageType, if l < l[1] then stDevLo else 0, averageLength);
def rviHi = if avgStDevHiUp + avgStDevHiDown == 0 then 50 else 100 * avgStDevHiUp / (avgStDevHiUp + avgStDevHiDown);
def rviLo = if avgStDevLoUp + avgStDevLoDown == 0 then 50 else 100 * avgStDevLoUp / (avgStDevLoUp + avgStDevLoDown);
plot RVI = (rviHi + rviLo) / 2;
}

script VPN {
input h = high;
input c = close;
input l = low;
input v = volume;
input length = 30;
input emaLength = 3;
input averageLength = 30;
input factor = 0.1;
input criticalValue = 10;
input averageType = AverageType.SIMPLE;
def hlc = (h + c + l)/3;
def tr = TrueRange(h, c, l);
def atr = WildersAverage(tr, length);
def diff = hlc - hlc[1];
def vp = Sum(if diff > factor * atr then v else 0, length);
def vn = Sum(if diff < -factor * atr then v else 0, length);
plot VPN = ExpAverage(100 * (vp - vn) / Sum(v, length), emaLength);
}
script CCI {
    input hi = high;
    input cl = close;
    input lo = low;
    input length = 14;
    def price = cl + lo + hi;
    def linDev = LinDev(price, length);
    plot CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
}
script CMO {
    input curClose = close;
    input length = 20;
    def prevClose = curClose[1];
    def inc = if curClose > prevClose then curClose - prevClose else 0;
    def dec = if prevClose > curClose then prevClose - curClose else 0;
    def sumInc = Sum(inc, length);
    def sumDec = Sum(dec, length);
    plot CMO = if sumInc + sumDec == 0 then 0 else (sumInc - sumDec) / (sumInc + sumDec) * 100;
}
#normalize(series float src, float min, float max) =>
script normalize {
    input src = close;
    input min = 0;
    input max = 100;
    def _historicMin1 =  100000000000;
    def _historicMax1 =  0.00000000001;
    def _historicMin = Min(src, Min(_historicMin[1], _historicMin1));
    def _historicMax = Max(src, Max(_historicMax[1], _historicMax1));
    def normalize = min + (max - min) * (src - _historicMin) / Max(_historicMax - _historicMin, 0.00000000001);
    plot out = normalize;
}
#rescale(series float src, float oldMin, float oldMax, float newMin, float newMax) =>
script rescale {
    input src = close;
    input oldMin = -100;
    input oldMax = 100;
    input newMin = 0;
    input newMax = 100;
    def rescale = newMin + (newMax - newMin) * (src - oldMin) / Max(oldMax - oldMin, 0.00000000001);
    plot out = rescale;
}
# --- Colors
DefineGlobalColor("colorwhite" , Color.WHITE);
DefineGlobalColor("colorblue"  , CreateColor(102, 51, 255));
DefineGlobalColor("colorred"   , CreateColor(255, 51, 51));
DefineGlobalColor("colorblue2" , CreateColor(51, 204, 255));
DefineGlobalColor("colorpink"  , CreateColor(255, 51, 102));
def nRSI1 = RSI(PRICE = src, LENGTH = len);
def nRSI2 = RSI(PRICE = src, LENGTH = len2);
def RSI = rescale(ExpAverage(nRSI1, 3), 0, 100, 0, 100);
def RSI2 = rescale(ExpAverage(nRSI2, 3), 0, 100, 0, 100);
#-- CMO--
def nCMO1 = CMO(src, len);
def nCMO2 = CMO(src, len2);
def cmo  = rescale(ExpAverage(nCMO1, 3), -100, 100, 0, 100);
def cmo2 =  rescale(ExpAverage(nCMO2, 3), -100, 100, 0, 100);
#--CCI
def nCCI1 = CCI(h, src, l, len);
def nCCI2 = CCI(h, src, l, len2);
def CCI = normalize(ExpAverage(nCCI1, 3), 0, 100);
def CCI2 = normalize(ExpAverage(nCCI2, 3), 0, 100);
#-- RVI
def nRVI1 = RVI(h, l ,len);
def nRVI2 = RVI(h, l, len2);
def rvi = rescale(ExpAverage(nRVI1, 3), 0, 100, 0, 100);
def rvi2 = rescale(ExpAverage(nRVI2, 3), 0, 100, 0, 100);
#-- VPN
def nVPN1 = VPN(h, src, l, v, len);
def nVPN2 = VPN(h, src, l, v, len2);
def vpn  = rescale(ExpAverage(nVPN1, 3), -50, 50, 0, 100);
def vpn2 =  rescale(ExpAverage(nVPN2, 3), -50, 50, 0, 100);
#-- MF
def MoneyFlow1 = Sum(if src < src[1] then -src * v else if src > src[1] then src * v else 0, len);
def MoneyFlow2 = Sum(if src < src[1] then -src * v else if src > src[1] then src * v else 0, len2);
def MF = Average(MoneyFlow1, 1);
def mf2 = Average(MoneyFlow2, 1);

def osc = if OscSrc == OscSrc.RSI then RSI else
          if OscSrc == OscSrc.MFI then MF else
          if OscSrc == OscSrc.CCI then CCI else
          if OscSrc == OscSrc.RVI then rvi else
          if OscSrc == OscSrc.CMO then cmo else vpn;

def osc2 = if OscSrc == OscSrc.RSI then RSI2 else
           if OscSrc == OscSrc.MFI then mf2 else
           if OscSrc == OscSrc.CCI then CCI2 else
           if OscSrc == OscSrc.RVI then rvi2 else
           if OscSrc == OscSrc.CMO then cmo2 else vpn2;

def Bullish = osc > osc2;
def Bearish = osc < osc2;
def Fukuizcolor = if Bullish then 1 else if Bearish then -1 else 0;

#//Plot//
plot l1 = osc;#, 'RSI Short', color=Fukuizcolor, linewidth=2, style=plot.style_line)
l1.SetLineWeight(2);
l1.AssignValueColor(if Fukuizcolor > 0 then GlobalColor("colorblue") else
                    if Fukuizcolor < 0 then GlobalColor("colorred") else Color.GRAY);
plot l2 = osc2;#, 'RSI Long', color=Fukuizcolor2, linewidth=2, style=plot.style_line)
l2.SetLineWeight(2);
l2.AssignValueColor(if Fukuizcolor > 0 then GlobalColor("colorblue") else
                    if Fukuizcolor < 0 then GlobalColor("colorred") else Color.GRAY);

plot band2 = if last then na else (Overbought + Oversold) / 2;#, 'Middle Band', color=#FFCC99)
band2.SetDefaultColor(Color.GRAY);
band2.SetStyle(Curve.SHORT_DASH);
plot band1 = if last then na else Overbought;#, 'Upper Band', color=#FFCC99)
band1.SetDefaultColor(Color.GRAY);
plot band0 = if last then na else Oversold;#, 'Lower Band', color=#FFCC99)
band0.SetDefaultColor(Color.GRAY);


AddCloud(band1, band0, CreateColor(48, 6, 80));#new(#0946CA, 90), title='Background')
AddCloud(l1, l2, GlobalColor("colorblue"), GlobalColor("colorred"));#color=Fukuizcolor3, title='Trend Background')

#----Div-----------
input LookBackRight  = 5;           # "Pivot Lookback Right"
input LookBackLeft  = 5;           # "Pivot Lookback Left"
input MaxLookback = 60;   # "Max of Lookback Range"
input MinLookback = 5;    # "Min of Lookback Range"
input DivBull = yes;      # "Plot Bullish"
input DivHiddenBull = no; # "Plot Hidden Bullish"
input DivBear = yes;      # "Plot Bearish"
input DivHiddenBear = no; # "Plot Hidden Bearish"
def divSrc = osc;

#def h = high;
#def l = low;

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
    if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
#valuewhen (Cond, source, lbr, occurrence)
script valuewhen {
    input cond = 0;
    input src = close;
    input MinLookback = 5;
    input MaxLookback = 60;
    input occurrence = 0;
    def n = occurrence + 1;
    def offset = fold j = MinLookback to MaxLookback + 1 with p=1 while p < n + 1
    do p + ( if p == n then j - n else if cond[j] == yes then 1 else 0 );
    plot price = GetValue(src, offset - 1);
}
#_inRange(cond) =>
script _inRange {
    input cond = yes;
    input rangeUpper = 60;
    input rangeLower = 5;
    def bars = if cond then 0 else bars[1] + 1;
    def inrange =  (rangeLower <= bars) and (bars <= rangeUpper);
    plot retrun = inrange;
}
def pl = findpivots(divSrc, -1, LookBackLeft, LookBackRight);
def ph = findpivots(divSrc, 1, LookBackLeft, LookBackRight);

def plFound = if !IsNaN(pl) then 1 else 0;
def phFound = if !IsNaN(ph) then 1 else 0;

def vlFound = valuewhen(plFound, divSrc, MinLookback, MaxLookback, 1);
def vhFound = valuewhen(phFound, divSrc, MinLookback, MaxLookback, 1);

def plPrice = valuewhen(plFound, l, MinLookback, MaxLookback, 1);
def phPrice = valuewhen(phFound, h, MinLookback, MaxLookback, 1);

#// Regular Bullish
def oscHL = divSrc > vlFound and  _inRange(plFound[1], MaxLookback, MinLookback);
def priceLL = l < plPrice;
def bullCond = DivBull and plFound and oscHL and priceLL;
#// Hidden Bullish
def oscLL = divSrc < vlFound and  _inRange(plFound[1], MaxLookback, MinLookback);
def priceHL = l > plPrice;
def hiddenBullCond = DivHiddenBull and plFound and oscLL and priceHL;

#// Regular Bearish
def oscLH   = divSrc < vhFound and  _inRange(phFound[1], MaxLookback, MinLookback);
def priceHH = h > phPrice;
def bearCond = DivBear and phFound and oscLH and priceHH;
#// Hidden Bearish
def oscHH = divSrc > vhFound and  _inRange(phFound[1], MaxLookback, MinLookback);
def priceLH = h < phPrice;
def hiddenBearCond = DivHiddenBear and phFound and oscHH and priceLH;

#------ Bubbles
AddChartBubble(bullCond, divSrc, "R", Color.GREEN, no);
AddChartBubble(bearCond, divSrc, "R", CreateColor(156, 39, 176), yes);
AddChartBubble(hiddenBullCond, divSrc, "H", Color.DARK_GREEN, no);
AddChartBubble(hiddenBearCond, divSrc, "H", Color.DARK_RED, yes);

#--- END CODE
Thank you so much ...its working
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
365 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top