• Get $40 off VIP by signing up for a free account! Sign Up

L3 Banker Fund Flow Trend Oscillator for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
nwChYWj.png


Author Message:

Background
The large funds or banker fund are often referred to as Whale. Whale can have a significant impact on the price movements in various markets, especially in cryptocurrency . Therefore, how to monitor Whale trends is of great significance both in terms of fundamentals and technical aspects.

Function
L3 Banker Fund Flow Trend Oscillator can give you a model of complete banker fund flow operation in cycles. Although the script is not so complicated, it is comprehensive to disclose the price trend. That is the reason why I list this as Level 3. Each cycle of banker fund flow may have 5 steps in max as entry, increase position, decrease position, exit, and weak rebound for exit.

Key Signal
1. banker fund entry with blue candle
2. banker increase position with green candle
3. banker decrease position with white candle
4. banker fund exit/quit with red candle
5. banker fund weak rebound with pink candle

Pros and Cons
Pros:
1. Model banker fund behavior in complete cycles
2. Overbought and oversold can be directly observed due to oscillator nature
3. the transition points are clear for entry or exit

Cons:
1. Simple modelling, no further complex behaviors can be disclosed
2. trade by trend following the banker fund, it is still under the trend analysis prerequisite

CODE - Added divergences and plot style - 06/2024

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
# Update - added option for MTF - 02/2024
# updated - Added plot option and Divergences - 06/2024

declare lower;
#//functions
input BarColor = no;
input plotStyle = {Default "Candles", "Lines"};
input showSignalLine = yes;
input timeframe = {default "Chart", "Custom"};
input customTimeframe = AggregationPeriod.FIFTEEN_MIN;
input SourceType = {"High/Low",default "Open/Close"};
input smoothingType = AverageType.EXPONENTIAL;
input SmoothingLength = 13;
input upperThreshold = 75;
input lowerThreshold = 25;

def na = Double.NaN;
def last = IsNaN(close);
def can = plotStyle==plotStyle."Candles";
def tf = customTimeframe;
def c;
def h;
def l;
def o;
def typ;
switch (timeframe) {
case "Custom" :
    c = close(Period = tf);
    h = high(Period = tf);
    l = low(Period = tf);
    o = open(Period = tf);
    typ = (2 * close(Period = tf) + high(Period = tf) + low(Period = tf) + open(Period = tf)) / 5;
default :
    c = close;
    h = high;
    l = low;
    o = open;
    typ = (2 * close + high + low + open) / 5;
}
#//define typical price for banker fund
def hilo = SourceType == SourceType."High/Low";
def srcHi = if hilo then h else Max(o, c);
def srcLo = if hilo then l else Min(o, c);
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val = fold i = 0 to length + 1 with p=Double.NaN do
            if (IsNaN(p) or !IsNaN(values[i])) then values[i] else p;
    plot out = if length >= 1 then r_val else Double.NaN;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    def ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    def out  = CompoundValue(1, (src * wei + out[1] * (len - wei)) / len, ma);
    plot return = out;
}

def hh = Highest(h, 27);
def ll = Lowest(l, 27);
def wmCal = (c - ll) / (hh - ll) * 100;
def xsaWM5 = xsa(wmCal, 5, 1);
def xsaWM3 = xsa(xsaWM5, 3, 1);
#//set up a simple model of banker fund flow trend   
def fundtrend = (3 * xsaWM5 - 2 * xsaWM3 - 50) * 1.032 + 50;

#//lowest low with mid term fib # 34
def lol = Lowest(srcLo, 34);
#//highest high with mid term fib # 34
def hoh = Highest(srcHi, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = MovingAverage(smoothingType, bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = (fundtrend Crosses Above bullbearline) and bullbearline < lowerThreshold;
def bankerExit  = (fundtrend Crosses Below bullbearline) and bullbearline > upperThreshold;

#//banker increase position with green candle
def xrf1 = xrf(fundtrend * 0.95, 1);
def UpCandle = if last or !can then na else fundtrend > bullbearline;
def WeakUp   = if last or !can then na else fundtrend < xrf1;
def DnCandle = if last or !can then na else fundtrend < bullbearline;
def WeakDn   = if last or !can then na else fundtrend < bullbearline and fundtrend > xrf1;

#-- clouds
def weak = !can and fundtrend < xrf1;
AddCloud(if weak or weak[1] then fundtrend else na, bullbearline, Color.DARK_GREEN, Color.RED, yes);
AddCloud(if can then na else fundtrend, bullbearline, Color.GREEN, Color.DARK_RED, yes);

# Plot the new Chart
#//banker fund entry with yellow candle
def condUp = bankerentry and !bankerentry[1];
def condDn = bankerExit and !bankerExit[1];
plot SigUp = if !showSignalLine then na else if condUp then 15 else 0;
plot SigDn = if !showSignalLine then na else if condDn then 85 else 100;

SigUp.AssignValueColor(if condUp or condUp[1] then Color.YELLOW else CreateColor(98, 98, 0));
SigDn.AssignValueColor(if condDn or condDn[1] then Color.MAGENTA else CreateColor(98, 0, 98));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor = CreateColor(7, 205, 15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  Color.LIGHT_GREEN); #CreateColor(188, 245, 188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;

plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(117, 117, 0));
AddCloud(h4, h1, Color.PLUM);

#-- bar Color
def col = if isNaN(fundtrend) then col[1] else
         if fundtrend > 100 then 255 else if fundtrend<0 then 0 else fundtrend * 2.55;

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if bankerExit then Color.MAGENTA else CreateColor(255 - col, col, 0));

#----Div-----------
input ShowLastDivLines = yes;
input DivBull = yes;      # "Plot Bullish"
input DivBear = yes;      # "Plot Bearish"
input PivotLookbackRight = 5;  # "Pivot Lookback Right"
input PivotLookbackLeft  = 10; # "Pivot Lookback Left"
input MaxLookback = 60;   # "Max of Lookback Range"
input MinLookback = 5;    # "Min of Lookback Range"

def divSrc = fundtrend;
def maxx = Max(fundtrend, bullbearline);
def minn = Min(fundtrend, bullbearline);

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 + 1 and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL + 1 and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
#_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, PivotLookbackLeft, PivotLookbackRight);
def ph_ = findpivots(divSrc, 1, PivotLookbackLeft, PivotLookbackRight);
def pl = !isNaN(pl_);
def ph = !isNaN(ph_);
def pll = lowest(divSrc,PivotLookbackLeft +1);
def phh = highest(divSrc,PivotLookbackLeft+1);
def sll = lowest(l, PivotLookbackLeft +1);
def shh = highest(h, PivotLookbackLeft+1);
#-- Pvt Low
def plStart  = if pl then yes else plStart[1];
def plFound  = if (plStart and pl) then 1 else 0;
def vlFound1 = if plFound then divSrc else vlFound1[1];
def vlFound_ = if vlFound1!=vlFound1[1] then vlFound1[1] else vlFound_[1];
def vlFound  = if !vlFound_ then pll else vlFound_;
def plPrice1 = if plFound then l else plPrice1[1];
def plPrice_ = if plPrice1!=plPrice1[1] then plPrice1[1] else plPrice_[1];
def plPrice  = if !plPrice_ then sll else plPrice_;
#-- Pvt High
def phStart = if ph then yes else phStart[1];
def phFound = if (phStart and ph) then 1 else 0;
def vhFound1 = if phFound then divSrc else vhFound1[1];
def vhFound_ = if vhFound1!=vhFound1[1] then vhFound1[1] else vhFound_[1];
def vhFound = if !vhFound_ then phh else vhFound_;
def phPrice1 = if phFound then h else phPrice1[1];
def phPrice_ = if phPrice1!=phPrice1[1] then phPrice1[1] else phPrice_[1];
def phPrice = if !phPrice_ then shh else phPrice_;
#// Regular Bullish
def inRangePl = _inRange(plFound[1],MaxLookback,MinLookback);
def oscHL = divSrc > vlFound and inRangePl;
def priceLL = l < plPrice and divSrc <= 40;
def bullCond = plFound and oscHL and priceLL;

#// Regular Bearish
def inRangePh = _inRange(phFound[1],MaxLookback,MinLookback);
def oscLH   = divSrc < vhFound and inRangePh;
def priceHH = h > phPrice and divSrc >= 60;
def bearCond = phFound and oscLH and priceHH;

#------ Bubbles
def bullBub  = DivBull and bullCond;
def bearBub  = DivBear and bearCond;

addchartbubble(bullBub, minn, "R", Color.CYAN, no);
addchartbubble(bearBub, maxx, "R", CreateColor(176,39,176), yes);

##### Lines
def bar = BarNumber();
#-- Bear Line
def lastPhBar = if ph then bar else lastPhBar[1];
def prePhBar = if lastPhBar!=lastPhBar[1] then lastPhBar[1] else prePhBar[1];
def priorPHBar = if bearCond then prePhBar else priorPHBar[1];
#-- Bull Line
def lastPlBar = if pl then bar else lastPlBar[1];
def prePlBar = if lastPlBar!=lastPlBar[1] then lastPlBar[1] else prePlBar[1];
def priorPLBar = if bullCond then prePlBar else priorPLBar[1];

def lastBullBar = if bullCond then bar else lastBullBar[1];
def lastBearBar = if bearCond then bar else lastBearBar[1];

def hiStart = bar == HighestAll(priorPHBar);
def hiEnd   = bar == HighestAll(lastBearBar);
def loStart = bar == HighestAll(priorPLBar);
def loEnd   = bar == HighestAll(lastBullBar);

def pivotHigh = if hiStart then maxx else if hiEnd then maxx else na;#if HighPivots then bullbearline else na;
def pivotLow  = if loStart then minn else if loEnd then minn else na;

plot PlotHline = if ShowLastDivLines then pivotHigh else na;
PlotHline.EnableApproximation();
PlotHline.SetDefaultColor(Color.WHITE);
PlotHline.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);

plot PlotLline = if ShowLastDivLines then pivotLow else na;
PlotLline.EnableApproximation();
PlotLline.SetDefaultColor(Color.CYAN);
PlotLline.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);


#---- END CODE
CODE :

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
declare lower;
#//functions
input BarColor = yes;
input SmoothingLength = 13;
def na = Double.NaN;
def last = isNaN(close[1]);
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend  
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
#//lowest low with mid term fib # 34
def lol = Lowest(low, 34);
#//highest high with mid term fib # 34
def hoh = Highest(high, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp   = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn   = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)
AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if WeakDn then Color.DARK_RED else
                 if DnCandle then Color.RED else
                 if WeakUp then Color.DARK_GREEN else
                 if UpCandle then Color.GREEN else Color.CURRENT);



#---- END CODE
 
Last edited:

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

nwChYWj.png


Author Message:

Background
The large funds or banker fund are often referred to as Whale. Whale can have a significant impact on the price movements in various markets, especially in cryptocurrency . Therefore, how to monitor Whale trends is of great significance both in terms of fundamentals and technical aspects.

Function
L3 Banker Fund Flow Trend Oscillator can give you a model of complete banker fund flow operation in cycles. Although the script is not so complicated, it is comprehensive to disclose the price trend. That is the reason why I list this as Level 3. Each cycle of banker fund flow may have 5 steps in max as entry, increase position, decrease position, exit, and weak rebound for exit.

Key Signal
1. banker fund entry with blue candle
2. banker increase position with green candle
3. banker decrease position with white candle
4. banker fund exit/quit with red candle
5. banker fund weak rebound with pink candle

Pros and Cons
Pros:
1. Model banker fund behavior in complete cycles
2. Overbought and oversold can be directly observed due to oscillator nature
3. the transition points are clear for entry or exit

Cons:
1. Simple modelling, no further complex behaviors can be disclosed
2. trade by trend following the banker fund, it is still under the trend analysis prerequisite

CODE :

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
declare lower;
#//functions
input BarColor = yes;
input SmoothingLength = 13;
def na = Double.NaN;
def last = isNaN(close[1]);
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend  
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
#//lowest low with mid term fib # 34
def lol = Lowest(low, 34);
#//highest high with mid term fib # 34
def hoh = Highest(high, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp   = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn   = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)
AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if WeakDn then Color.DARK_RED else
                 if DnCandle then Color.RED else
                 if WeakUp then Color.DARK_GREEN else
                 if UpCandle then Color.GREEN else Color.CURRENT);



#---- END CODE
Thanks @samer800 ... took this new baby for a ride ... works very well with my existing setup!!! many thanks
 
nwChYWj.png


Author Message:

Background
The large funds or banker fund are often referred to as Whale. Whale can have a significant impact on the price movements in various markets, especially in cryptocurrency . Therefore, how to monitor Whale trends is of great significance both in terms of fundamentals and technical aspects.

Function
L3 Banker Fund Flow Trend Oscillator can give you a model of complete banker fund flow operation in cycles. Although the script is not so complicated, it is comprehensive to disclose the price trend. That is the reason why I list this as Level 3. Each cycle of banker fund flow may have 5 steps in max as entry, increase position, decrease position, exit, and weak rebound for exit.

Key Signal
1. banker fund entry with blue candle
2. banker increase position with green candle
3. banker decrease position with white candle
4. banker fund exit/quit with red candle
5. banker fund weak rebound with pink candle

Pros and Cons
Pros:
1. Model banker fund behavior in complete cycles
2. Overbought and oversold can be directly observed due to oscillator nature
3. the transition points are clear for entry or exit

Cons:
1. Simple modelling, no further complex behaviors can be disclosed
2. trade by trend following the banker fund, it is still under the trend analysis prerequisite

CODE :

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
declare lower;
#//functions
input BarColor = yes;
input SmoothingLength = 13;
def na = Double.NaN;
def last = isNaN(close[1]);
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend  
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
#//lowest low with mid term fib # 34
def lol = Lowest(low, 34);
#//highest high with mid term fib # 34
def hoh = Highest(high, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp   = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn   = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)
AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if WeakDn then Color.DARK_RED else
                 if DnCandle then Color.RED else
                 if WeakUp then Color.DARK_GREEN else
                 if UpCandle then Color.GREEN else Color.CURRENT);



#---- END CODE
@Sammy800 great job like always, thank you some much!!!


@samer800 quick question i just saw for long entry, do you think the short may be good? thanks
 
Last edited by a moderator:
nwChYWj.png


Author Message:

Background
The large funds or banker fund are often referred to as Whale. Whale can have a significant impact on the price movements in various markets, especially in cryptocurrency . Therefore, how to monitor Whale trends is of great significance both in terms of fundamentals and technical aspects.

Function
L3 Banker Fund Flow Trend Oscillator can give you a model of complete banker fund flow operation in cycles. Although the script is not so complicated, it is comprehensive to disclose the price trend. That is the reason why I list this as Level 3. Each cycle of banker fund flow may have 5 steps in max as entry, increase position, decrease position, exit, and weak rebound for exit.

Key Signal
1. banker fund entry with blue candle
2. banker increase position with green candle
3. banker decrease position with white candle
4. banker fund exit/quit with red candle
5. banker fund weak rebound with pink candle

Pros and Cons
Pros:
1. Model banker fund behavior in complete cycles
2. Overbought and oversold can be directly observed due to oscillator nature
3. the transition points are clear for entry or exit

Cons:
1. Simple modelling, no further complex behaviors can be disclosed
2. trade by trend following the banker fund, it is still under the trend analysis prerequisite

CODE :

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
declare lower;
#//functions
input BarColor = yes;
input SmoothingLength = 13;
def na = Double.NaN;
def last = isNaN(close[1]);
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend  
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
#//lowest low with mid term fib # 34
def lol = Lowest(low, 34);
#//highest high with mid term fib # 34
def hoh = Highest(high, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp   = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn   = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)
AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if WeakDn then Color.DARK_RED else
                 if DnCandle then Color.RED else
                 if WeakUp then Color.DARK_GREEN else
                 if UpCandle then Color.GREEN else Color.CURRENT);



#---- END CODE
@samer800 i really like this indicator, im sorry to bother you , do you think it is possible to add the scan for it? thank you in advance
 
@samer800 i really like this indicator, im sorry to bother you , do you think it is possible to add the scan for it? thank you in advance
try this

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
# Scan
#input BarColor = yes;
#input SmoothingLength = 13;
def na = Double.NaN;
def last = isNaN(close[1]);
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend   
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
#//lowest low with mid term fib # 34
def lol = Lowest(low, 34);
#//highest high with mid term fib # 34
def hoh = Highest(high, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, 13);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;

# Plot the new Chart
#//banker fund entry with yellow candle

plot scan = bankerentry within 3 bars;


#---- END CODE
 
nwChYWj.png


Author Message:

Background
The large funds or banker fund are often referred to as Whale. Whale can have a significant impact on the price movements in various markets, especially in cryptocurrency . Therefore, how to monitor Whale trends is of great significance both in terms of fundamentals and technical aspects.

Function
L3 Banker Fund Flow Trend Oscillator can give you a model of complete banker fund flow operation in cycles. Although the script is not so complicated, it is comprehensive to disclose the price trend. That is the reason why I list this as Level 3. Each cycle of banker fund flow may have 5 steps in max as entry, increase position, decrease position, exit, and weak rebound for exit.

Key Signal
1. banker fund entry with blue candle
2. banker increase position with green candle
3. banker decrease position with white candle
4. banker fund exit/quit with red candle
5. banker fund weak rebound with pink candle

Pros and Cons
Pros:
1. Model banker fund behavior in complete cycles
2. Overbought and oversold can be directly observed due to oscillator nature
3. the transition points are clear for entry or exit

Cons:
1. Simple modelling, no further complex behaviors can be disclosed
2. trade by trend following the banker fund, it is still under the trend analysis prerequisite

CODE :

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
declare lower;
#//functions
input BarColor = yes;
input SmoothingLength = 13;
def na = Double.NaN;
def last = isNaN(close[1]);
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend 
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
#//lowest low with mid term fib # 34
def lol = Lowest(low, 34);
#//highest high with mid term fib # 34
def hoh = Highest(high, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp   = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn   = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)
AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if WeakDn then Color.DARK_RED else
                 if DnCandle then Color.RED else
                 if WeakUp then Color.DARK_GREEN else
                 if UpCandle then Color.GREEN else Color.CURRENT);



#---- END CODE

Thanks as always @samer800 . Does this repaint?

Following up @samer800 👋😁

The developer doesn't always know? I didn't know that but noted. I'll watch it Tuesday and see (y)
 
Last edited by a moderator:
Thanks as always @samer800 . Does this repaint?

Following up @samer800 👋😁

The developer doesn't always know? I didn't know that but noted. I'll watch it Tuesday and see (y)

mod note:
There is nothing in the code that indicates any repainting behavior.
Except: obviously, the current candle will update every tick (repaint) until it closes.
This is true with all charts, all platforms, whether you put any indicators on your chart.
Because it is not possible to know what the current candle close is going to be until it actually closes.

FYI, here is how to know if an indicator on the forum repaints:
  1. If an indicator in this forum contains apparent repainting logic, the thread will be labeled with the "repaints" prefix.
  2. There's always a chance that something might have been missed. Thus, if you observe any repainting activity on CLOSED candles, it's recommended that you make a post.
  3. When expressing your concerns, please provide detailed information about the specific behavior you're witnessing.
Also, including a chart link is always beneficial. The behavior you're seeing could be triggered by a different indicator.

If you're unsure of how to share chart links:
How to create a shared chart link:
https://usethinkscript.com/threads/how-to-share-a-chart-in-thinkorswim.14221/

@IPA
I have no idea what BlackCat, the developer knows or doesn't know. That would be a conversation that you would need to have over on Tradingview.
@samer800 is a scripter of great renown, who has been unceasingly generous in converting these scripts, but he is not the author of them.
 
Last edited:
Not seeing how you would short with this strategy.
Can you share what your idea would be?
Agree, if possible, would be nice to have a short colored candle as signal for banker entry short, possibly magenta, on upper chart when bar color = yes; which then also corresponds with lower indicator producing magenta vertical bar for short trade.

Basically just the opposite of what we have now in blue for banker entry but for a short in different color to visualize between long and short which depicts alignment on both upper chart candle and lower indicator.
 
Agree, if possible, would be nice to have a short colored candle as signal for banker entry short, possibly magenta, on upper chart when bar color = yes; which then also corresponds with lower indicator producing magenta vertical bar for short trade.

Basically just the opposite of what we have now in blue for banker entry but for a short in different color to visualize between long and short which depicts alignment on both upper chart candle and lower indicator.
I added short option but not sure how accurate, need further testing.

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
declare lower;
#//functions
input BarColor = yes;
input SmoothingLength = 13;
def na = Double.NaN;
def last = isNaN(close[1]);
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend   
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
#//lowest low with mid term fib # 34
def lol = Lowest(typ, 34);
#//highest high with mid term fib # 34
def hoh = Highest(typ, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;
def bankerExit = Crosses(fundtrend, bullbearline, CrossingDirection.BELOW) and bullbearline > 75;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp   = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn   = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerExit then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  Color.DARK_RED);

AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)
AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if bankerExit then Color.MAGENTA else
                 if WeakDn then Color.DARK_RED else
                 if DnCandle then Color.RED else
                 if WeakUp then Color.DARK_GREEN else
                 if UpCandle then Color.GREEN else Color.CURRENT);



#---- END CODE
 
Hi Samer, thanks for giving that a go. The visualization is great with the magenta for bankerexit.

I need to study and compare changes. One thing I noticed right away is the bankerentry signals (cyan) changed and gave more signals, not sure why.

I compared code line by line between the original and new version and seems like the bankerentry code remains unchanged in new version, however the way it functions changed and gave more & different signals even though it seems the only code added overall was for bankerexit as shown below. I didnt see any bankerentry changes.

row 45 def bankerExit = Crosses(fundtrend, bullbearline, CrossingDirection.BELOW) and bullbearline > 75;
row 55 AddChart(high = if bankerExit then 100 else na, low = 0 , open = 100, close = 0,
row 56 type = ChartType.CANDLE, growcolor = Color.DARK_RED);
row 86 if bankerExit then Color.MAGENTA else

I probably dont't fully understand the orignal design concept but thought multi-directional signals visualizing the entry and exit would add value.

Thanks you for your efforts!
 
Hi Samer, thanks for giving that a go. The visualization is great with the magenta for bankerexit.

I need to study and compare changes. One thing I noticed right away is the bankerentry signals (cyan) changed and gave more signals, not sure why.

I compared code line by line between the original and new version and seems like the bankerentry code remains unchanged in new version, however the way it functions changed and gave more & different signals even though it seems the only code added overall was for bankerexit as shown below. I didnt see any bankerentry changes.

row 45 def bankerExit = Crosses(fundtrend, bullbearline, CrossingDirection.BELOW) and bullbearline > 75;
row 55 AddChart(high = if bankerExit then 100 else na, low = 0 , open = 100, close = 0,
row 56 type = ChartType.CANDLE, growcolor = Color.DARK_RED);
row 86 if bankerExit then Color.MAGENTA else

I probably dont't fully understand the orignal design concept but thought multi-directional signals visualizing the entry and exit would add value.

Thanks you for your efforts!
you are correct, the change on related to high and low. change the below and will be same like old code.
def lol = Lowest(low, 34);
def hoh = Highest(high, 34);
 
you are correct, the change on related to high and low. change the below and will be same like old code.
def lol = Lowest(low, 34);
def hoh = Highest(high, 34);
@samer800 please can you update the file, i dont know how to or where to put this line here to the original code. thank you in advance
 
you are correct, the change on related to high and low. change the below and will be same like old code.
def lol = Lowest(low, 34);
def hoh = Highest(high, 34);
Thanks for that I made the change and everything looks good. Appreciate all your coding!
 
@samer800 please can you update the file, i dont know how to or where to put this line here to the original code. thank you in advance
Pleased note I change some color coding but all the logic and function is for the latest version with bankerexit:

#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
declare lower;
#//functions
input BarColor = yes;
input SmoothingLength = 13;
def na = Double.NaN;
def last = isNaN(close[1]);
#xrf(values, length) =>
script xrf {
input values = close;
input length = 34;
def r_val;# = float(na)
r_val = if length >= 1 then
fold i = 0 to length +1 with p=values do
if IsNaN(p) or !IsNaN(values) then values else p else Double.NaN;
plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
input src = close;
input len = 5;
input wei = 1;
def sumf;# = 0.0
def ma;# = 0.0
def out;# = 0.0
sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
ma = if IsNaN(src[len]) then Double.NaN else sumf / len;
out = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
#//lowest low with mid term fib # 34
#def lol = Lowest(typ, 34);#new code
def lol = Lowest(low, 34);#orig code
#//highest high with mid term fib # 34
#def hoh = Highest(typ, 34);#new code
def hoh = Highest(high, 34);#orig code
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;
def bankerExit = Crosses(fundtrend, bullbearline, CrossingDirection.BELOW) and bullbearline > 75;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerExit then 100 else na, low = 0 , open = 100, close = 0,
type = ChartType.CANDLE, growcolor = Color.magenta);

AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100, close = 0,
type = ChartType.CANDLE, growcolor = color.blue); #original CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend, close = bullbearline,
type = ChartType.CANDLE, growcolor = CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend, close = bullbearline,
type = ChartType.CANDLE, growcolor = CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline, close = fundtrend,
type = ChartType.CANDLE, growcolor = Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline, close = fundtrend,
type = ChartType.CANDLE, growcolor = Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.dark_GRAY);

#AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)#original
AddCloud(h2, h3, Color.Light_gray);#color=color.yellow,transp=70)#mark new
#AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)#original
AddCloud(h4, h1, Color.Light_gray);#=color.fuchsia,transp=70)#new mark

AssignPriceColor(if !BarColor then Color.CURRENT else
if bankerentry then Color.blue else
if bankerExit then Color.MAGENTA else
if WeakDn then Color.DARK_RED else
if DnCandle then Color.RED else
if WeakUp then Color.DARK_GREEN else
if UpCandle then Color.GREEN else Color.CURRENT);



#---- END CODE
 
@samer800 please can you update the file, i dont know how to or where to put this line here to the original code. thank you in advance
check the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
# Update - added option for source selection
declare lower;
#//functions
input BarColor = no;
input SmoothingLength = 13;
input SourceType = {Default "High/Low", "CCHOL"};
def na = Double.NaN;
def last = isNaN(close[1]);
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
def type = SourceType==SourceType."High/Low";
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend   
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;

#//lowest low with mid term fib # 34
def lol = Lowest(if type then low else typ, 34);
#//highest high with mid term fib # 34
def hoh = Highest(if type then high else typ, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;
def bankerExit = Crosses(fundtrend, bullbearline, CrossingDirection.BELOW) and bullbearline > 75;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp   = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn   = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerExit then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  Color.DARK_RED);

AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)
AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if bankerExit then Color.MAGENTA else
                 if WeakDn then Color.DARK_RED else
                 if DnCandle then Color.RED else
                 if WeakUp then Color.DARK_GREEN else
                 if UpCandle then Color.GREEN else Color.CURRENT);

#---- END CODE
 
check the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
# Update - added option for source selection
declare lower;
#//functions
input BarColor = no;
input SmoothingLength = 13;
input SourceType = {Default "High/Low", "CCHOL"};
def na = Double.NaN;
def last = isNaN(close[1]);
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
def type = SourceType==SourceType."High/Low";
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend  
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;

#//lowest low with mid term fib # 34
def lol = Lowest(if type then low else typ, 34);
#//highest high with mid term fib # 34
def hoh = Highest(if type then high else typ, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;
def bankerExit = Crosses(fundtrend, bullbearline, CrossingDirection.BELOW) and bullbearline > 75;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp   = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn   = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerExit then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  Color.DARK_RED);

AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)
AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if bankerExit then Color.MAGENTA else
                 if WeakDn then Color.DARK_RED else
                 if DnCandle then Color.RED else
                 if WeakUp then Color.DARK_GREEN else
                 if UpCandle then Color.GREEN else Color.CURRENT);

#---- END CODE
THanks @samer800
May I know if this can be used for any timeframe or intraday?

Thanks
 
check the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L3 Banker Fund Flow Trend Oscillator", overlay=false)
# Converted and mod by Sam4Cok@Samer800 - 02/2023
# Update - added option for source selection
declare lower;
#//functions
input BarColor = no;
input SmoothingLength = 13;
input SourceType = {Default "High/Low", "CCHOL"};
def na = Double.NaN;
def last = isNaN(close[1]);
#//define typical price for banker fund
def typ = (2 * close + high + low + open) / 5;
def type = SourceType==SourceType."High/Low";
#xrf(values, length) =>
script xrf {
    input values = close;
    input length = 34;
    def r_val;# = float(na)
    r_val = if length >= 1 then
                fold i = 0 to length +1 with p=values do
             if IsNaN(p) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
    plot out = r_val;
}
#xsa(src,len,wei) =>
script xsa {
    input src = close;
    input len = 5;
    input wei = 1;
    def sumf;# = 0.0
    def ma;# = 0.0
    def out;# = 0.0
    sumf = CompoundValue(1, sumf[1] - src[len] + src , src);
    ma   = if IsNaN(src[len]) then Double.NaN else sumf / len;
    out  = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len;
    plot return = out;
}
def wmCal = (close - Lowest(low, 27)) / (Highest(high, 27) - Lowest(low, 27)) * 100;

#//set up a simple model of banker fund flow trend  
def fundtrend = (3 * xsa(wmCal, 5, 1) - 2 * xsa(xsa(wmCal, 5, 1), 3, 1) - 50) * 1.032 + 50;

#//lowest low with mid term fib # 34
def lol = Lowest(if type then low else typ, 34);
#//highest high with mid term fib # 34
def hoh = Highest(if type then high else typ, 34);
#//define banker fund flow bull bear line
def bullbear = (typ - lol) / (hoh - lol) * 100;
def bullbearline = ExpAverage(bullbear, SmoothingLength);
#//define banker entry signal
def bankerentry = Crosses(fundtrend, bullbearline, CrossingDirection.ABOVE) and bullbearline < 25;
def bankerExit = Crosses(fundtrend, bullbearline, CrossingDirection.BELOW) and bullbearline > 75;

#//banker increase position with green candle
def UpCandle = fundtrend > bullbearline;
def WeakUp   = fundtrend < (xrf(fundtrend * 0.95, 1));
def DnCandle = fundtrend < bullbearline;
def WeakDn   = fundtrend < bullbearline and fundtrend > (xrf(fundtrend * 0.95, 1));

# Plot the new Chart
#//banker fund entry with yellow candle
AddChart(high = if bankerExit then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  Color.DARK_RED);

AddChart(high = if bankerentry then 100 else na, low = 0 , open = 100,  close = 0,
         type = ChartType.CANDLE, growcolor =  CreateColor(26, 70, 85));

AddChart(high = if UpCandle then bullbearline else na , low = fundtrend , open = fundtrend,  close =  bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(7,205,15));

AddChart(high = if WeakUp then bullbearline else na , low = fundtrend , open = fundtrend,  close = bullbearline,
         type = ChartType.CANDLE, growcolor =  CreateColor(188,245,188));

AddChart(high = if DnCandle then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.RED);

AddChart(high = if WeakDn then bullbearline else na , low = fundtrend , open = bullbearline,  close =   fundtrend,
         type = ChartType.CANDLE, growcolor =  Color.PINK);

#/overbought and oversold threshold lines
def h1 = if last then na else 80;
def h2 = if last then na else 20;
def h3 = 10;
def h4 = 90;
plot h5 = if last then na else 50;
h5.SetDefaultColor(Color.DARK_GRAY);

AddCloud(h2, h3, CreateColor(157,157,0));#color=color.yellow,transp=70)
AddCloud(h4, h1, CreateColor(157,0 ,157));#=color.fuchsia,transp=70)

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if bankerentry then Color.CYAN else
                 if bankerExit then Color.MAGENTA else
                 if WeakDn then Color.DARK_RED else
                 if DnCandle then Color.RED else
                 if WeakUp then Color.DARK_GREEN else
                 if UpCandle then Color.GREEN else Color.CURRENT);

#---- END CODE

Very intriguing!

What's the primary change in this latest update? Does it have a "Short" signal?
I realize this is a lower study; however, on the original post there appears to be a cyan colored confirmation candle on the top chart. Is that from another study? I am not getting that on my chart.

Thank you
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
445 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