Bull Bear Power VOID Oscillator For ThinkOrSwim

Found another great indicator but in TV. @samer800 Would love to have this in TOS format. Help please! Thank you

https://www.tradingview.com/script/rAVwAuVi-Bull-Bear-Power-Void/

//Bull Beear Power VOID Oscillator by @CoffeeShopCrypto
//2022 Coded from my Kitchen and a bit from the Coffeeshop down the sreet.
//This indicator is NOT complete. Its an ongoing project and it will only get better.
//Alerts, and LONG SHORT indicators to come shortly
//@version=5
indicator("Bull Bear Power Void", shorttitle="BBP-Void", overlay=false)

src = input(defval = close, title = "Source", group="Bull BeaR Settings")
BBPlengthInput = input.int(50, title="Length", tooltip="Set to the level you want to break the most", group="Bull BeaR Settings")
bullPower = high - ta.ema(close, BBPlengthInput)
bearPower = low - ta.ema(close, BBPlengthInput)
//Calculate the Plot Range for Columns
//Moving Average Calculations inputs and plotting//
BullMA(source, length, type) =>
switch type
"SMA" => ta.sma(source, (length))
"EMA" => ta.ema(source, length)
"VWMA" => ta.vwma(source, length)
"VWAP" => ta.vwap(source)
BearMA(source, length, type) =>
switch type
"SMA" => ta.sma(source, (length))
"EMA" => ta.ema(source, length)
"VWMA" => ta.vwma(source, length)
"VWAP" => ta.vwap(source)

BullmaTypeInput = input.string("EMA", title="Moving Average Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "LSMA", "VWAP"], tooltip="Use the same Moving average as the one on your chart.", group="Bull Bear Moving Average")
BullmalengthInput = input.int(21, title="Moving Average Length", group="Bull Bear Moving Average")
//input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA", "LSMA", "VWAP"], tooltip="Smooths the HA candles.", group="RSI MA Settings")
//BearmaTypeInput = input.string("SMA", title="Bear MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "LSMA", "VWAP"], tooltip="Choose a moving average.", group="Bear Moving Average")
//BearmalengthInput = input.int(21, title="BBP-MA", group="Bear Moving Average")
//Moving Average Calculations
Bullma = BullMA(bullPower - bearPower, BullmalengthInput, BullmaTypeInput)
Bearma = BearMA(bearPower - bullPower, BullmalengthInput, BullmaTypeInput)
//BBP Moving Average Plot
//plot(BBPmov, title="BBP MA", color=color.yellow, linewidth=1, offset=0)
//---Lets Plot the custom Column colors for Bull Bear Columns:
// Plot colors
bull_grow_above = input(#0f7c0fc9, "Above Growing strength", group="Bull Bear Color Settings", inline="Above")
bull_fall_above = input(#a3c9a5c9, "Above Losing strength", group="Bull Bear Color Settings", inline="Above")
bear_grow_below = input(#dfb3b8c9, "Below Losing strength", group="Bull Bear Color Settings", inline="Below")
bear_fall_below = input(#ce2121d3, "Below Growing strength", group="Bull Bear Color Settings", inline="Below")
histo = bullPower + bearPower
hline(0, "Middle Band", color=color.new(#cc5b1f, 20))
//Lets Plot everything
//Plotting the Bull Bear Columns
//plot(bullPower + bearPower, title="BBPower Color / Columns", color=(histo>=0 ? (histo[1] < histo ? bull_grow_above : bull_fall_above) : (histo[1] < histo ? bear_grow_below : bear_fall_below)), linewidth=2, style=plot.style_columns, display=display.all)
//plot(Bullma, title="Bull Void MA", color=color.rgb(29, 102, 59, 60), linewidth=2, style=plot.style_area, offset=0)
//plot(Bearma, title="Bear Void MA", color=color.rgb(216, 60, 60, 60), linewidth=2, style=plot.style_area, offset=0)
//MACD Attempt
fast_length = input(title="Fast Length", defval=12, group="MACD Settings")
slow_length = input(title="Slow Length", defval=26, group="MACD Settings")
MACDsrc = input(title="Source", defval=close, group="MACD Settings")
signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9, group="MACD Settings")
sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"], group="MACD Settings")
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"], group="MACD Settings")
// Plot colors
col_macd = input(#2962FF, "MACD Line", inline="MACD", group="MACD Settings")
col_signal = input(#FF6D00, "Signal Line", inline="Signal", group="MACD Settings")

// Calculating
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length) * 10
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length) * 10
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
//plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below)))
//plot(macd, title="MACD", color=col_macd)
//plot(signal, title="Signal", color=col_signal)
//
///Trend Colors to make MACD Crosses more visible
float maxLine = Bearma
float minLine = Bullma
bool MACDBullish = macd > signal
color topColor = MACDBullish ? color.new(#2b0101, 0) : color.new(#bf6332, 0)
color botColor = MACDBullish ? color.new(#2962ff, 0) : color.new(#040c09, 0)
float topLineValue = MACDBullish ? maxLine : maxLine
float botLineValue = MACDBullish ? minLine : minLine
//macdplot = plot(macd, title="MACD", color=col_macd)
//signalplot = plot(signal, title="Signal", color=col_signal)
//fill(macdplot, signalplot, topLineValue, botLineValue, topColor, botColor, title="MACD Trend Colors")
///End MACD Trend Colors
//Lets Plot everything
//Plotting the Bull Bear Columns
macdplot = plot(macd, title="MACD", color=col_macd, display=display.none)
signalplot = plot(signal, title="Signal", color=col_signal, display=display.none)
fill(macdplot, signalplot, topLineValue, botLineValue, topColor, botColor, title="MACD Trend Colors")
plot(bullPower + bearPower, title="BBPower Color / Columns", color=(histo>=0 ? (histo[1] < histo ? bull_grow_above : bull_fall_above) : (histo[1] < histo ? bear_grow_below : bear_fall_below)), linewidth=2, style=plot.style_columns, display=display.all)
plot(Bullma, title="Bull Void MA", color=color.rgb(29, 102, 59, 35), linewidth=2, style=plot.style_area, offset=0)
plot(Bearma, title="Bear Void MA", color=color.rgb(216, 60, 60, 35), linewidth=2, style=plot.style_area, offset=0)
//This indicator is NOT complete. Its an ongoing project and it will only get better.
//Alerts, and LONG SHORT indicators to come shortly
check it out below.

CSS:
#/Bull Beear Power VOID Oscillator by @CoffeeShopCrypto
#//2022 Coded from my Kitchen and a bit from the Coffeeshop down the sreet.
#//This indicator is NOT complete. Its an ongoing project and it will only get better.
#//Alerts, and LONG SHORT indicators to come shortly
#indicator("Bull Bear Power Void", shorttitle="BBP-Void", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022
declare lower;
input src = close;
input PowerLength = 50;
input maTypeInput = {"SMA", default "EMA", "RMA", "WMA", "VWMA", "LSMA"};
input BullMaLength = 21;
input BearMaLength = 21;
input macdSrc = close;
input fast_length = 12;
input slow_length = 26;
input signal_length = 9;
input macdMaType   = {"SMA", default "EMA"};
input signalMaType = {"SMA", default "EMA"};

def na = Double.NaN;
#vwma(source, length)
script VWMA {
    input x = close;
    input y = 15;
    def VWMA = SimpleMovingAvg(x * volume, y) / SimpleMovingAvg(volume, y);
    plot result = VWMA;
}
#BullMA(source, length, type) =>
script MA {
    input source = close;
    ;
    input length = 21;
    input type = "EMA";
    def BullMA = if type == "EMA" then ExpAverage(source, length) else
                 if type == "SMA" then SimpleMovingAvg(source, length) else
                 if type == "WMA" then WMA(source, length) else
                 if type == "RMA" then WildersAverage(source, length) else
                 if type == "LSMA" then inertia(source, length) else
                 if type == "VWMA" then vwma(source, length) else Double.NaN;
    plot return = BullMA;
}
#---- Colors.
DefineGlobalColor("ZeroLine"   , CreateColor(204,91,31));
DefineGlobalColor("TopColUp"   , Color.MAGENTA);
DefineGlobalColor("TopColDn"   , Color.PLUM);
DefineGlobalColor("BotColUp"   , Color.LIGHT_GREEN);
DefineGlobalColor("BotColDn"   , Color.DARK_GREEN);
DefineGlobalColor("col_macd"   , CreateColor(41,98,255));
DefineGlobalColor("col_signal"   , CreateColor(255,109,0));

DefineGlobalColor("bull_up"   , CreateColor(15,124,15));
DefineGlobalColor("bull_dn" , CreateColor(163,201,165));
DefineGlobalColor("bear_dn"   , CreateColor(206,33,33));
DefineGlobalColor("bear_up" , CreateColor(223,179,184));

DefineGlobalColor("bull"   , Color.GREEN);
DefineGlobalColor("bear" , Color.RED);
def h = high; def l = low; def c = close;

def bullPower = h - MA(c, PowerLength, maTypeInput);
def bearPower = l - MA(c, PowerLength,maTypeInput);
def power = bullPower + bearPower;
#//Moving Average Calculations inputs and plotting//

def Bullma = MA(bullPower - bearPower, BullMaLength, maTypeInput);
def Bearma = MA(bearPower - bullPower, BearMaLength, maTypeInput);

def histo = bullPower + bearPower;
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GlobalColor("ZeroLine"));

#// Calculating
def fastMA = MA(src, fast_length, macdMaType);
def slowMA = MA(src, slow_length, macdMaType);
def fast_ma = if macdMaType == macdMaType."SMA" then fastMA else fastMA * 10;
def slow_ma = if macdMaType == macdMaType."SMA" then slowMA else slowMA * 10;
def macd = fast_ma - slow_ma;
def signal = MA(macd, signal_length, signalMaType);
def hist = macd - signal;

#//Trend Colors to make MACD Crosses more visible
def maxLine = Bearma;
def minLine = Bullma;
def MACDBullish = macd > signal;
def color= if histo>=0 then
           if histo[1] < histo then 2 else 1 else
           if histo[1] < histo then -1 else -2;
def  topLineValue = if MACDBullish then maxLine else maxLine;
def  botLineValue = if MACDBullish then minLine else minLine;
#///End MACD Trend Colors

#//Lets Plot everything
#//Plotting the Bull Bear Columns
def Bull = Bullma;
def Bear = Bearma;
def macdplot = macd;
def signalplot = signal;

AddCloud(bull,0, GlobalColor("bull"));
AddCloud(0,bear, GlobalColor("bear"));
AddCloud(if macd>0 then na else signal, macd, GlobalColor("TopColUp"), GlobalColor("TopColDn"));
AddCloud(if macd<0 then na else macd, signal, GlobalColor("BotColUp"), GlobalColor("BotColDn"));#

plot BBPower = power;
BBPower.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
BBPower.AssignValueColor(if color==2 then GlobalColor("bull_up") else
                         if color==1 then GlobalColor("bull_dn") else
                         if color==-1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));

#--- END Code

Updated with the new code from the author and added signal line.

CODE#2:

CSS:
#/Bull Beear Power VOID Oscillator by @CoffeeShopCrypto
#//2022 Coded from my Kitchen and a bit from the Coffeeshop down the sreet.
#//This indicator is NOT complete. Its an ongoing project and it will only get better.
#//Alerts, and LONG SHORT indicators to come shortly
#indicator("Bull Bear Power Void", shorttitle="BBP-Void", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022
# updated the code & style Sam4Cok@Samer800 - 11/2022
declare lower;
input src = close;
input ColorBar = yes;
input SignalLine = yes;
input BullBearHistogram = yes;
input PowerLength = 50;
input macdType = {Default "MACD-TRADITIONAL", "MACD-AS (HISTOGRAM)", "MACD-LEADER", "MACD-SOURCE"}; #"MACD Calculation Method"
input maTypeInput = {"SMA", "EMA", "RMA", "WMA",default "VWMA", "LSMA"};
input BullBearMaType = {"SMA", default "EMA"};
input BullBearMaLength = 21;
input macdSrc = close;
input fast_length = 12;
input slow_length = 26;
input signal_length = 9;
input macdMaType   = {"SMA", default "EMA"};


def na = Double.NaN;
def macdCalc = if macdType==macdType."MACD-TRADITIONAL" then 1 else
               if macdType==macdType."MACD-AS (HISTOGRAM)" then 2 else
               if macdType==macdType."MACD-LEADER" then 3 else 4;
#vwma(source, length)
script VWMA {
    input x = close;
    input y = 15;
    def VWMA = SimpleMovingAvg(x * volume, y) / SimpleMovingAvg(volume, y);
    plot result = VWMA;
}
#BullMA(source, length, type) =>
script MA {
    input source = close;
    ;
    input length = 21;
    input type = "EMA";
    def MA = if type == "EMA" then ExpAverage(source, length) else
             if type == "SMA" then SimpleMovingAvg(source, length) else
             if type == "WMA" then WMA(source, length) else
             if type == "RMA" then WildersAverage(source, length) else
             if type == "LSMA" then Inertia(source, length) else
             if type == "VWMA" then vwma(source, length) else Double.NaN;
    plot return = MA;
}
#---- Colors.
DefineGlobalColor("BotColUp", Color.MAGENTA);
DefineGlobalColor("TopColUp", Color.CYAN);
DefineGlobalColor("noColor", CreateColor(17,17,17));
DefineGlobalColor("bull_up" , CreateColor(18, 147, 18));
DefineGlobalColor("bull_dn" , CreateColor(163,201,165));
DefineGlobalColor("bear_dn" , CreateColor(206,33,33));
DefineGlobalColor("bear_up" , Color.PINK);
DefineGlobalColor("bull" , CreateColor(115,173,118));
DefineGlobalColor("bear" , CreateColor(208,143,150));
def h = high;
def l = low;
def c = close;

#//Moving Average Calculations inputs and plotting//
def bullPower = h - ma(c, PowerLength,BullBearMaType);
def bearPower = l - ma(c, PowerLength,BullBearMaType);
def Bullma = MA(bullPower - bearPower, BullBearMaLength, maTypeInput);
def Bearma = MA(bearPower - bullPower, BullBearMaLength, maTypeInput);
def power = bullPower + bearPower;
def histo = power;
def hist   = if !BullBearHistogram then na else if histo>=0 then Bullma else Bearma;

#// MACD Attempt
def fastMA = MA(src, fast_length, macdMaType);
def slowMA = MA(src, slow_length, macdMaType);
def fast_ma = if macdMaType == macdMaType."SMA" then fastMA else fastMA * 10;
def slow_ma = if macdMaType == macdMaType."SMA" then slowMA else slowMA * 10;
def diff = fast_ma - slow_ma;
def macd1= if macdCalc==1 then diff else
           if macdCalc==2 then diff - ma(diff, signal_length, macdMaType) else
           if macdCalc==3 then diff + ma(src - fast_ma, fast_length, macdMaType) - ma(src - slow_ma, slow_length, macdMaType)
           else  ma(src - (fastMA+slowMA)/2, signal_length, macdMaType) * 10;
def signal1 = MA(macd1, signal_length, macdMaType);
def macd = macd1;
def signal = signal1;

#///Trend Colors to make MACD Crosses more visible
def maxLine = Bearma;
def minLine = Bullma;
def MACDBullish = macd > signal;
def topColor = if MACDBullish then 0 else 1;
def botColor = if MACDBullish then 1 else 0;
def topLineValue = if MACDBullish then maxLine else maxLine;
def botLineValue = if MACDBullish then minLine else minLine;

def color = if histo >= 0 then
            if histo[1] < histo then 2 else 1 else
            if histo[1] < histo then -1 else -2;
#///End MACD Trend Colors
#//Lets Plot everything
#//Plotting the Bull Bear Columns
plot ZeroLine = if isNaN(c) then na else 0;
ZeroLine.SetDefaultColor(Color.GRAY);
plot BBPower = histo;
BBPower.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BBPower.AssignValueColor(if color == 2 then GlobalColor("bull_up") else
                         if color == 1 then GlobalColor("bull_dn") else
                         if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));
BBPower.SetLineWeight(3);

plot bbLine = hist;
bbLine.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
bbLine.AssignValueColor(if bbLine>=0 then GlobalColor("bull") else GlobalColor("bear"));
#--- Cloud
addCloud(if BullBearHistogram then na else minLine, 0, GlobalColor("bull"));
addCloud(if BullBearHistogram then na else 0, maxLine, GlobalColor("bear"));
AddCloud(if topColor and botLineValue < signal then macd else signal,if topColor and botLineValue < signal then signal else macd , GlobalColor("BotColUp"), GlobalColor("noColor"));
AddCloud(if botColor and topLineValue > signal then signal else macd,if botColor and topLineValue > signal then macd else signal, GlobalColor("TopColUp"), GlobalColor("noColor"));

#--- Signal
def SellBar = if signal > macd and (signal<maxLine and macd<maxLine) and color<0 then SellBar[1] + 1 else 0;
def BuyBar  = if signal < macd and (signal>minLine and macd>minLine) and color>0 then BuyBar[1] + 1 else 0;
def crossDn = if (macd < signal and signal > minLine and color < 2) then crossDn[1]+1 else 0;
def crossUp = if (macd > signal and signal < maxLine and color > -2) then crossUp[1]+1 else 0;

plot Bear = if !SignalLine then na else if crossDn==1 then 5 else na;
Bear.SetPaintingStrategy(PaintingStrategy.POINTS);
Bear.SetDefaultColor(Color.RED);
Bear.SetLineWeight(3);
plot bull = if !SignalLine then na else if crossUp==1 then 5 else na;
bull.SetPaintingStrategy(PaintingStrategy.POINTS);
bull.SetDefaultColor(Color.GREEN);
bull.SetLineWeight(3);
#---- price color
AssignPriceColor(if !ColorBar then color.CURRENT else
if SellBar==2 then color.MAGENTA else
if BuyBar==2 then Color.CYAN else
if color == 2 then GlobalColor("bull_up") else
if color == 1 then GlobalColor("bull_dn") else
if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));
#--- END CODE

yJpafAp.png

background color added and signal line updated
CODE:
CSS:
#/Bull Beear Power VOID Oscillator by @CoffeeShopCrypto
#//2022 Coded from my Kitchen and a bit from the Coffeeshop down the sreet.
#//This indicator is NOT complete. Its an ongoing project and it will only get better.
#//Alerts, and LONG SHORT indicators to come shortly
#indicator("Bull Bear Power Void", shorttitle="BBP-Void", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022
# updated the code & style Sam4Cok@Samer800 - 11/2022
# updated the signal line and added background Color - 12/2022
declare lower;
input src = close;
input ColorBar = yes;
input BackgroundColor = yes;
input SignalLine = yes;
input BullBearHistogram = yes;
input PowerLength = 50;
input macdType = {Default "MACD-TRADITIONAL", "MACD-AS (HISTOGRAM)", "MACD-LEADER", "MACD-SOURCE"}; #"MACD Calculation Method"
input maTypeInput = {"SMA", "EMA", "RMA", "WMA",default "VWMA", "LSMA"};
input BullBearMaType = {"SMA", default "EMA"};
input BullBearMaLength = 21;
input macdSrc = close;
input fast_length = 20;
input slow_length = 50;
input signal_length = 14;
input macdMaType   = {"SMA", default "EMA"};

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def macdCalc = if macdType==macdType."MACD-TRADITIONAL" then 1 else
               if macdType==macdType."MACD-AS (HISTOGRAM)" then 2 else
               if macdType==macdType."MACD-LEADER" then 3 else 4;
#vwma(source, length)
script VWMA {
    input x = close;
    input y = 21;
    def VWMA = SimpleMovingAvg(x * volume, y) / SimpleMovingAvg(volume, y);
    plot result = VWMA;
}
#BullMA(source, length, type) =>
script MA {
    input source = close;
    ;
    input length = 21;
    input type = "EMA";
    def MA = if type == "EMA" then ExpAverage(source, length) else
             if type == "SMA" then SimpleMovingAvg(source, length) else
             if type == "WMA" then WMA(source, length) else
             if type == "RMA" then WildersAverage(source, length) else
             if type == "LSMA" then Inertia(source, length) else
             if type == "VWMA" then vwma(source, length) else Double.NaN;
    plot return = MA;
}
#---- Colors.
DefineGlobalColor("BotColUp", Color.MAGENTA);
DefineGlobalColor("TopColUp", Color.CYAN);
DefineGlobalColor("noColor", CreateColor(17,17,17));
DefineGlobalColor("bull_up" , CreateColor(18, 147, 18));
DefineGlobalColor("bull_dn" , CreateColor(163,201,165));
DefineGlobalColor("bear_dn" , CreateColor(206,33,33));
DefineGlobalColor("bear_up" , Color.PINK);
DefineGlobalColor("bull" , CreateColor(115,173,118));
DefineGlobalColor("bear" , CreateColor(208,143,150));
def h = high;
def l = low;
def c = close;

#//Moving Average Calculations inputs and plotting//
def bullPower = h - ma(c, PowerLength,BullBearMaType);
def bearPower = l - ma(c, PowerLength,BullBearMaType);
def Bullma = MA(bullPower - bearPower, BullBearMaLength, maTypeInput);
def Bearma = MA(bearPower - bullPower, BullBearMaLength, maTypeInput);
def power = bullPower + bearPower;
def histo = power;
def hist   = if !BullBearHistogram then na else if histo>=0 then Bullma else Bearma;

#// MACD Attempt
def fastMA = MA(src, fast_length, macdMaType);
def slowMA = MA(src, slow_length, macdMaType);
def fast_ma = if macdMaType == macdMaType."SMA" then fastMA else fastMA * 10;
def slow_ma = if macdMaType == macdMaType."SMA" then slowMA else slowMA * 10;
def diff = fast_ma - slow_ma;
def macd1= if macdCalc==1 then diff else
           if macdCalc==2 then diff - ma(diff, signal_length, macdMaType) else
           if macdCalc==3 then diff + ma(src - fast_ma, fast_length, macdMaType) - ma(src - slow_ma, slow_length, macdMaType)
           else  ma(src - (fastMA+slowMA)/2, signal_length, macdMaType) * 10;
def signal1 = MA(macd1, signal_length, macdMaType);
def macd = macd1;
def signal = signal1;

#///Trend Colors to make MACD Crosses more visible
def maxLine = Bearma;
def minLine = Bullma;
def MACDBullish = macd > signal;
def topColor = if MACDBullish then 0 else 1;
def botColor = if MACDBullish then 1 else 0;
def topLineValue = if MACDBullish then maxLine else maxLine;
def botLineValue = if MACDBullish then minLine else minLine;

def color = if histo >= 0 then
            if histo[1] < histo then 2 else 1 else
            if histo[1] < histo then -1 else -2;
#///End MACD Trend Colors
#//Lets Plot everything
#//Plotting the Bull Bear Columns
plot ZeroLine = if isNaN(c) then na else 0;
ZeroLine.SetDefaultColor(Color.GRAY);
plot BBPower = histo;
BBPower.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BBPower.AssignValueColor(if color == 2 then GlobalColor("bull_up") else
                         if color == 1 then GlobalColor("bull_dn") else
                         if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));
BBPower.SetLineWeight(3);

plot bbLine = hist;
bbLine.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
bbLine.AssignValueColor(if bbLine>=0 then GlobalColor("bull") else GlobalColor("bear"));
#--- Cloud
addCloud(if BullBearHistogram then na else minLine, 0, GlobalColor("bull"));
addCloud(if BullBearHistogram then na else 0, maxLine, GlobalColor("bear"));
AddCloud(if topColor and botLineValue < signal then macd else signal,if topColor and botLineValue < signal then signal else macd , GlobalColor("BotColUp"), GlobalColor("noColor"));
AddCloud(if botColor and topLineValue > signal then signal else macd,if botColor and topLineValue > signal then macd else signal, GlobalColor("TopColUp"), GlobalColor("noColor"));

#--- Signal
def SellBar = if signal > macd and (signal<maxLine and macd<maxLine) and color<0 then SellBar[1] + 1 else 0;
def BuyBar  = if signal < macd and (signal>minLine and macd>minLine) and color>0 then BuyBar[1] + 1 else 0;

plot Bear = if !SignalLine then na else if SellBar==2 then 5 else na;
Bear.SetPaintingStrategy(PaintingStrategy.POINTS);
Bear.SetDefaultColor(Color.RED);
Bear.SetLineWeight(3);
plot bull = if !SignalLine then na else if BuyBar==2 then 5 else na;
bull.SetPaintingStrategy(PaintingStrategy.POINTS);
bull.SetDefaultColor(Color.GREEN);
bull.SetLineWeight(3);
#---- price color
AssignPriceColor(if !ColorBar then color.CURRENT else
if SellBar==2 then color.MAGENTA else
if BuyBar==2 then Color.CYAN else
if color == 2 then GlobalColor("bull_up") else
if color == 1 then GlobalColor("bull_dn") else
if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));

#--- BackGround
def volumetrend = if macd > signal and signal >= 0 then 1 else
                  if macd < signal and signal <= 0 then -1 else 0;

AddCloud(if !BackgroundColor then na else if volumetrend>0 then pos else if volumetrend<0 then neg else na, if volumetrend>0 then neg else pos, Color.DARK_GREEN, Color.DARK_RED);

#--- END CODE
 
Last edited by a moderator:
is it possible for the blue and black cloud to show up on the chart or arrows?
this changed the whole code. I just created this with multiple options for you.

CSS:
# MACD Signal - as requested from useThinkscript.com member
# Created by Sam4Cok@Samer800 - 11/2022

declare Upper;
input src = close;
input Trendfreckles = yes;
input signalStyle = {Default Arrows, BarColor, Both, None};
input SignalBarConfirm = 1;
input macdType = {Default "MACD-TRADITIONAL", "MACD-AS (HISTOGRAM)", "MACD-LEADER", "MACD-SOURCE"}; #"MACD Calculation Method"
input macdMaType   = {"SMA", default "EMA", "RMA", "WMA", "VWMA", "LSMA"};
input signalMaType = {"SMA", default "EMA", "RMA", "WMA", "VWMA", "LSMA"};
input fast_length = 12;
input slow_length = 26;
input signal_length = 9;

def na = Double.NaN;
def h = high;
def l = low;
def c = close;
def macdCalc = if macdType==macdType."MACD-TRADITIONAL" then 1 else
               if macdType==macdType."MACD-AS (HISTOGRAM)" then 2 else
               if macdType==macdType."MACD-LEADER" then 3 else 4;

def SigType  = if signalStyle==signalStyle.Both then 2 else
               if signalStyle==signalStyle.BarColor then 1 else
               if signalStyle==signalStyle.Arrows then -1 else 0;
#vwma(source, length)
script VWMA {
    input x = close;
    input y = 15;
    def VWMA = SimpleMovingAvg(x * volume, y) / SimpleMovingAvg(volume, y);
    plot result = VWMA;
}
#BullMA(source, length, type) =>
script MA {
    input source = close;
    ;
    input length = 21;
    input type = "EMA";
    def BullMA = if type == "EMA" then ExpAverage(source, length) else
                 if type == "SMA" then SimpleMovingAvg(source, length) else
                 if type == "WMA" then WMA(source, length) else
                 if type == "RMA" then WildersAverage(source, length) else
                 if type == "LSMA" then Inertia(source, length) else
                 if type == "VWMA" then vwma(source, length) else Double.NaN;
    plot return = BullMA;
}
#// Calculating
def fastMA = MA(src, fast_length, macdMaType);
def slowMA = MA(src, slow_length, macdMaType);
def diff = fastMA - slowMA;
def macd1= if macdCalc==1 then diff else
           if macdCalc==2 then diff - ma(diff, signal_length, macdMaType) else
           if macdCalc==3 then diff + ma(src - fastMA, fast_length, macdMaType) - ma(src - slowMA, slow_length, macdMaType)
           else  ma(src - (fastMA+slowMA)/2, signal_length, macdMaType);
def signal1 = MA(macd1, signal_length, signalMaType);
def macd = macd1;
def signal = signal1;

#--- Signal
def SellBar = if signal > macd and (signal>0 and macd>0) then SellBar[1] + 1 else 0;
def BuyBar  = if signal < macd and (signal<0 and macd<0) then BuyBar[1] + 1 else 0;

def Sellfrac = if signal > macd and (signal<0 and macd<0) then Sellfrac[1] + 1 else 0;
def Buyfrac = if signal < macd and (signal>0 and macd>0) then Buyfrac[1] + 1 else 0;

plot Bearfreckles = if !Trendfreckles then na else if Sellfrac then h else na;
plot Bullfreckles = if !Trendfreckles then na else if Buyfrac  then l else na;
Bearfreckles.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
Bullfreckles.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
Bearfreckles.SetDefaultColor(Color.MAGENTA);
Bullfreckles.SetDefaultColor(Color.CYAN);

plot ArrowUp = if SigType==1 or SigType==0 then na else if BuyBar==SignalBarConfirm then l else na;
plot ArrowDn = if SigType==1 or SigType==0 then na else if SellBar==SignalBarConfirm then h else na;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowDn.SetDefaultColor(Color.MAGENTA);
ArrowUp.SetDefaultColor(Color.CYAN);
ArrowUp.SetLineWeight(2);
ArrowDn.SetLineWeight(2);

AssignPriceColor(if SigType<=0 then Color.CURRENT else if SellBar==SignalBarConfirm then color.MAGENTA else if BuyBar==SignalBarConfirm then Color.CYAN else Color.CURRENT);

#--- END Code
 
this changed the whole code. I just created this with multiple options for you.

CSS:
# MACD Signal - as requested from useThinkscript.com member
# Created by Sam4Cok@Samer800 - 11/2022

declare Upper;
input src = close;
input Trendfreckles = yes;
input signalStyle = {Default Arrows, BarColor, Both, None};
input SignalBarConfirm = 1;
input macdType = {Default "MACD-TRADITIONAL", "MACD-AS (HISTOGRAM)", "MACD-LEADER", "MACD-SOURCE"}; #"MACD Calculation Method"
input macdMaType   = {"SMA", default "EMA", "RMA", "WMA", "VWMA", "LSMA"};
input signalMaType = {"SMA", default "EMA", "RMA", "WMA", "VWMA", "LSMA"};
input fast_length = 12;
input slow_length = 26;
input signal_length = 9;

def na = Double.NaN;
def h = high;
def l = low;
def c = close;
def macdCalc = if macdType==macdType."MACD-TRADITIONAL" then 1 else
               if macdType==macdType."MACD-AS (HISTOGRAM)" then 2 else
               if macdType==macdType."MACD-LEADER" then 3 else 4;

def SigType  = if signalStyle==signalStyle.Both then 2 else
               if signalStyle==signalStyle.BarColor then 1 else
               if signalStyle==signalStyle.Arrows then -1 else 0;
#vwma(source, length)
script VWMA {
    input x = close;
    input y = 15;
    def VWMA = SimpleMovingAvg(x * volume, y) / SimpleMovingAvg(volume, y);
    plot result = VWMA;
}
#BullMA(source, length, type) =>
script MA {
    input source = close;
    ;
    input length = 21;
    input type = "EMA";
    def BullMA = if type == "EMA" then ExpAverage(source, length) else
                 if type == "SMA" then SimpleMovingAvg(source, length) else
                 if type == "WMA" then WMA(source, length) else
                 if type == "RMA" then WildersAverage(source, length) else
                 if type == "LSMA" then Inertia(source, length) else
                 if type == "VWMA" then vwma(source, length) else Double.NaN;
    plot return = BullMA;
}
#// Calculating
def fastMA = MA(src, fast_length, macdMaType);
def slowMA = MA(src, slow_length, macdMaType);
def diff = fastMA - slowMA;
def macd1= if macdCalc==1 then diff else
           if macdCalc==2 then diff - ma(diff, signal_length, macdMaType) else
           if macdCalc==3 then diff + ma(src - fastMA, fast_length, macdMaType) - ma(src - slowMA, slow_length, macdMaType)
           else  ma(src - (fastMA+slowMA)/2, signal_length, macdMaType);
def signal1 = MA(macd1, signal_length, signalMaType);
def macd = macd1;
def signal = signal1;

#--- Signal
def SellBar = if signal > macd and (signal>0 and macd>0) then SellBar[1] + 1 else 0;
def BuyBar  = if signal < macd and (signal<0 and macd<0) then BuyBar[1] + 1 else 0;

def Sellfrac = if signal > macd and (signal<0 and macd<0) then Sellfrac[1] + 1 else 0;
def Buyfrac = if signal < macd and (signal>0 and macd>0) then Buyfrac[1] + 1 else 0;

plot Bearfreckles = if !Trendfreckles then na else if Sellfrac then h else na;
plot Bullfreckles = if !Trendfreckles then na else if Buyfrac  then l else na;
Bearfreckles.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
Bullfreckles.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
Bearfreckles.SetDefaultColor(Color.MAGENTA);
Bullfreckles.SetDefaultColor(Color.CYAN);

plot ArrowUp = if SigType==1 or SigType==0 then na else if BuyBar==SignalBarConfirm then l else na;
plot ArrowDn = if SigType==1 or SigType==0 then na else if SellBar==SignalBarConfirm then h else na;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowDn.SetDefaultColor(Color.MAGENTA);
ArrowUp.SetDefaultColor(Color.CYAN);
ArrowUp.SetLineWeight(2);
ArrowDn.SetLineWeight(2);

AssignPriceColor(if SigType<=0 then Color.CURRENT else if SellBar==SignalBarConfirm then color.MAGENTA else if BuyBar==SignalBarConfirm then Color.CYAN else Color.CURRENT);

#--- END Code
@samer800 like always great job, i noticed the assignpricecolor option is not working, is not changes the candles color, do you think it is possible to add a input where we can select color bar? like you always add on your scrips. thank you very much
 
@samer800 like always great job, i noticed the assignpricecolor option is not working, is not changes the candles color, do you think it is possible to add a input where we can select color bar? like you always add on your scrips. thank you very much
added as requested
CSS:
#/Bull Beear Power VOID Oscillator by @CoffeeShopCrypto
#//2022 Coded from my Kitchen and a bit from the Coffeeshop down the sreet.
#//This indicator is NOT complete. Its an ongoing project and it will only get better.
#//Alerts, and LONG SHORT indicators to come shortly
#indicator("Bull Bear Power Void", shorttitle="BBP-Void", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022
declare lower;
input src = close;
input ColorBar = yes;
input ShowMacdHistogram = yes;
input PowerLength = 50;
input macdType = {Default "MACD-TRADITIONAL", "MACD-AS (HISTOGRAM)", "MACD-LEADER", "MACD-SOURCE"}; #"MACD Calculation Method"
input maTypeInput = {"SMA", default "EMA", "RMA", "WMA", "VWMA", "LSMA"};
input BullMaLength = 21;
input BearMaLength = 21;
input macdSrc = close;
input fast_length = 12;
input slow_length = 26;
input signal_length = 9;
input macdMaType   = {"SMA", default "EMA"};
input signalMaType = {"SMA", default "EMA"};

def na = Double.NaN;
def macdCalc = if macdType==macdType."MACD-TRADITIONAL" then 1 else
               if macdType==macdType."MACD-AS (HISTOGRAM)" then 2 else
               if macdType==macdType."MACD-LEADER" then 3 else 4;
#vwma(source, length)
script VWMA {
    input x = close;
    input y = 15;
    def VWMA = SimpleMovingAvg(x * volume, y) / SimpleMovingAvg(volume, y);
    plot result = VWMA;
}
#BullMA(source, length, type) =>
script MA {
    input source = close;
    ;
    input length = 21;
    input type = "EMA";
    def BullMA = if type == "EMA" then ExpAverage(source, length) else
                 if type == "SMA" then SimpleMovingAvg(source, length) else
                 if type == "WMA" then WMA(source, length) else
                 if type == "RMA" then WildersAverage(source, length) else
                 if type == "LSMA" then Inertia(source, length) else
                 if type == "VWMA" then vwma(source, length) else Double.NaN;
    plot return = BullMA;
}
#---- Colors.
DefineGlobalColor("BotColUp"   , Color.MAGENTA);
DefineGlobalColor("BotColDn"   , CreateColor(43, 22, 40));
DefineGlobalColor("TopColUp"   , Color.CYAN);
DefineGlobalColor("TopColDn"   , CreateColor(1, 38, 43));

DefineGlobalColor("bull_up" , CreateColor(33,188,52));
DefineGlobalColor("bull_dn" , Color.LIGHT_GREEN);
DefineGlobalColor("bear_dn" , Color.RED);
DefineGlobalColor("bear_up" , Color.PINK);

DefineGlobalColor("bull" , Color.LIGHT_GREEN);
DefineGlobalColor("bear" , Color.PINK);
def h = high;
def l = low;
def c = close;

#//Moving Average Calculations inputs and plotting//
def bullPower = h - MA(c, PowerLength, maTypeInput);
def bearPower = l - MA(c, PowerLength, maTypeInput);
def power = bullPower + bearPower;
def powDiff =  (bullPower - bearPower);
def histo = power;
def hist   = if !ShowMacdHistogram then na else if histo>=0 then powDiff else -powDiff; #(macd - signal);

#// Calculating
def fastMA = MA(src, fast_length, macdMaType);
def slowMA = MA(src, slow_length, macdMaType);
def fast_ma = if macdMaType == macdMaType."SMA" then fastMA else fastMA * 10;
def slow_ma = if macdMaType == macdMaType."SMA" then slowMA else slowMA * 10;
def diff = fast_ma - slow_ma;
def macd1= if macdCalc==1 then diff else
           if macdCalc==2 then diff - ma(diff, signal_length, macdMaType) else
           if macdCalc==3 then diff + ma(src - fast_ma, fast_length, macdMaType) - ma(src - slow_ma, slow_length, macdMaType)
           else  ma(src - (fastMA+slowMA)/2, signal_length, macdMaType) * 10;
def signal1 = MA(macd1, signal_length, signalMaType);
def macd = macd1;
def signal = signal1;

#//Trend Colors to make MACD Crosses more visible

def color = if histo >= 0 then
            if histo[1] < histo then 2 else 1 else
            if histo[1] < histo then -1 else -2;
#///End MACD Trend Colors
#//Lets Plot everything
#//Plotting the Bull Bear Columns
plot ZeroLine = if isNaN(c) then na else 0;
ZeroLine.SetDefaultColor(Color.GRAY);
plot BBPower = histo;
BBPower.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BBPower.AssignValueColor(if color == 2 then GlobalColor("bull_up") else
                         if color == 1 then GlobalColor("bull_dn") else
                         if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));
BBPower.SetLineWeight(3);

plot bbLine = hist;
bbLine.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
bbLine.AssignValueColor(if bbLine>=0 then GlobalColor("bull") else GlobalColor("bear"));
#--- Cloud
AddCloud(if (signal > 0 or macd > 0) then na else signal, macd, GlobalColor("BotColUp"), GlobalColor("BotColDn"));
AddCloud(if (signal < 0 or macd < 0) then na else macd, signal, GlobalColor("TopColUp"), GlobalColor("TopColDn"));
AddCloud(if (signal > 0 or macd > 0 or signal < macd) then na else signal, macd, GlobalColor("BotColUp"));
AddCloud(if (signal < 0 or macd < 0 or signal > macd) then na else macd, signal, GlobalColor("TopColUp"));
AddCloud(if (signal > 0 or macd > 0 or signal < macd) then na else signal, macd, GlobalColor("BotColUp"));
AddCloud(if (signal < 0 or macd < 0 or signal > macd) then na else macd, signal, GlobalColor("TopColUp"));

#--- Signal
def SellBar = if signal > macd and (signal<-1 and macd<-1) and color<0 then SellBar[1] + 1 else 0;
def BuyBar  = if signal < macd and (signal>1 and macd>1) and color>0 then BuyBar[1] + 1 else 0;

AssignPriceColor(if !ColorBar then color.CURRENT else
if SellBar==2 then color.MAGENTA else
if BuyBar==2 then Color.CYAN else
if color == 2 then GlobalColor("bull_up") else
if color == 1 then GlobalColor("bull_dn") else
if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));
#--- END CODE
 
Last edited by a moderator:
check it out below.

CSS:
#/Bull Beear Power VOID Oscillator by @CoffeeShopCrypto
#//2022 Coded from my Kitchen and a bit from the Coffeeshop down the sreet.
#//This indicator is NOT complete. Its an ongoing project and it will only get better.
#//Alerts, and LONG SHORT indicators to come shortly
#indicator("Bull Bear Power Void", shorttitle="BBP-Void", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022
declare lower;
input src = close;
input PowerLength = 50;
input maTypeInput = {"SMA", default "EMA", "RMA", "WMA", "VWMA", "LSMA"};
input BullMaLength = 21;
input BearMaLength = 21;
input macdSrc = close;
input fast_length = 12;
input slow_length = 26;
input signal_length = 9;
input macdMaType   = {"SMA", default "EMA"};
input signalMaType = {"SMA", default "EMA"};

def na = Double.NaN;
#vwma(source, length)
script VWMA {
    input x = close;
    input y = 15;
    def VWMA = SimpleMovingAvg(x * volume, y) / SimpleMovingAvg(volume, y);
    plot result = VWMA;
}
#BullMA(source, length, type) =>
script MA {
    input source = close;
    ;
    input length = 21;
    input type = "EMA";
    def BullMA = if type == "EMA" then ExpAverage(source, length) else
                 if type == "SMA" then SimpleMovingAvg(source, length) else
                 if type == "WMA" then WMA(source, length) else
                 if type == "RMA" then WildersAverage(source, length) else
                 if type == "LSMA" then inertia(source, length) else
                 if type == "VWMA" then vwma(source, length) else Double.NaN;
    plot return = BullMA;
}
#---- Colors.
DefineGlobalColor("ZeroLine"   , CreateColor(204,91,31));
DefineGlobalColor("TopColUp"   , Color.MAGENTA);
DefineGlobalColor("TopColDn"   , Color.PLUM);
DefineGlobalColor("BotColUp"   , Color.LIGHT_GREEN);
DefineGlobalColor("BotColDn"   , Color.DARK_GREEN);
DefineGlobalColor("col_macd"   , CreateColor(41,98,255));
DefineGlobalColor("col_signal"   , CreateColor(255,109,0));

DefineGlobalColor("bull_up"   , CreateColor(15,124,15));
DefineGlobalColor("bull_dn" , CreateColor(163,201,165));
DefineGlobalColor("bear_dn"   , CreateColor(206,33,33));
DefineGlobalColor("bear_up" , CreateColor(223,179,184));

DefineGlobalColor("bull"   , Color.GREEN);
DefineGlobalColor("bear" , Color.RED);
def h = high; def l = low; def c = close;

def bullPower = h - MA(c, PowerLength, maTypeInput);
def bearPower = l - MA(c, PowerLength,maTypeInput);
def power = bullPower + bearPower;
#//Moving Average Calculations inputs and plotting//

def Bullma = MA(bullPower - bearPower, BullMaLength, maTypeInput);
def Bearma = MA(bearPower - bullPower, BearMaLength, maTypeInput);

def histo = bullPower + bearPower;
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GlobalColor("ZeroLine"));

#// Calculating
def fastMA = MA(src, fast_length, macdMaType);
def slowMA = MA(src, slow_length, macdMaType);
def fast_ma = if macdMaType == macdMaType."SMA" then fastMA else fastMA * 10;
def slow_ma = if macdMaType == macdMaType."SMA" then slowMA else slowMA * 10;
def macd = fast_ma - slow_ma;
def signal = MA(macd, signal_length, signalMaType);
def hist = macd - signal;

#//Trend Colors to make MACD Crosses more visible
def maxLine = Bearma;
def minLine = Bullma;
def MACDBullish = macd > signal;
def color= if histo>=0 then
           if histo[1] < histo then 2 else 1 else
           if histo[1] < histo then -1 else -2;
def  topLineValue = if MACDBullish then maxLine else maxLine;
def  botLineValue = if MACDBullish then minLine else minLine;
#///End MACD Trend Colors

#//Lets Plot everything
#//Plotting the Bull Bear Columns
def Bull = Bullma;
def Bear = Bearma;
def macdplot = macd;
def signalplot = signal;

AddCloud(bull,0, GlobalColor("bull"));
AddCloud(0,bear, GlobalColor("bear"));
AddCloud(if macd>0 then na else signal, macd, GlobalColor("TopColUp"), GlobalColor("TopColDn"));
AddCloud(if macd<0 then na else macd, signal, GlobalColor("BotColUp"), GlobalColor("BotColDn"));#

plot BBPower = power;
BBPower.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
BBPower.AssignValueColor(if color==2 then GlobalColor("bull_up") else
                         if color==1 then GlobalColor("bull_dn") else
                         if color==-1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));

#--- END Code
Here is an Image 5 Minutes /ES, for the above Indicator. Please comment how you interpret arrows The V & inverted V & Cloud Colors.
 
here is updated code for TV. Anyone want to try convert it to TOS?

https://www.tradingview.com/script/rAVwAuVi-Bull-Bear-Power-Void/

//@version=5
indicator("Bull Bear Power Void", shorttitle="BBP-Void", overlay=false)

src = input(defval = close, title = "Source", group="Bull BeaR Settings")
BBPlengthInput = input.int(50, title="Length", tooltip="Set to the level you want to break the most", group="Bull BeaR Settings")
bullPower = high - ta.ema(close, BBPlengthInput)
bearPower = low - ta.ema(close, BBPlengthInput)
//Calculate the Plot Range for Columns
//Moving Average Calculations inputs and plotting//
BullMA(source, length, type) =>
switch type
"VWMA" => ta.vwma(source, length)

BearMA(source, length, type) =>
switch type
"VWMA" => ta.vwma(source, length)
rsiLengthInput = 14, minval=1, title="RSI Length", step=1, group="Relative Strength Input Settings"
//BullmaTypeInput = input.string("VWMA", title="Moving Average Type", options=["VWMA"], group="Bull Bear Moving Average")
BullmaTypeInput = "VWMA"
BullmalengthInput = input.int(21, title="Moving Average Length", group="Bull Bear Moving Average")
//Moving Average Calculations
Bullma = BullMA(bullPower - bearPower, BullmalengthInput, BullmaTypeInput)
Bearma = BearMA(bearPower - bullPower, BullmalengthInput, BullmaTypeInput)
//---Lets Plot the custom Column colors for Bull Bear Columns:
// Plot colors
bull_grow_above = input(#0f7c0fc9, "Above Growing strength", group="Bull Bear Color Settings", inline="Above")
bull_fall_above = input(#a3c9a5c9, "Above Losing strength", group="Bull Bear Color Settings", inline="Above")
bear_grow_below = input(#dfb3b8c9, "Below Losing strength", group="Bull Bear Color Settings", inline="Below")
bear_fall_below = input(#ce2121d3, "Below Growing strength", group="Bull Bear Color Settings", inline="Below")
histo = bullPower + bearPower
hline(0, "Middle Band", color=color.new(#cc5b1f, 20))
//Lets Plot everything The MACD Lines with the multiplier calculation

//MACD Attempt
fast_length = input(title="Fast Length", defval=12, group="MACD Settings")
slow_length = input(title="Slow Length", defval=26, group="MACD Settings")
MACDsrc = input(title="Source", defval=close, group="MACD Settings")
signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9, group="MACD Settings")
sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"], group="MACD Settings")
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"], group="MACD Settings")
// Plot colors
col_macd = input(#2962FF, "MACD Line", inline="MACD", group="MACD Settings")
col_signal = input(#FF6D00, "Signal Line", inline="Signal", group="MACD Settings")

// Calculating
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length) * 10
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length) * 10
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal

///Trend Colors to make MACD Crosses more visible
float maxLine = Bearma
float minLine = Bullma
bool MACDBullish = macd > signal
color topColor = MACDBullish ? color.new(#2b0101, 0) : color.new(#bf6332, 0)
color botColor = MACDBullish ? color.new(#2962ff, 0) : color.new(#040c09, 0)
float topLineValue = MACDBullish ? maxLine : maxLine
float botLineValue = MACDBullish ? minLine : minLine
///End MACD Trend Colors
//Lets Plot everything
//Plotting the Bull Bear Columns
macdplot = plot(macd, title="MACD", color=col_macd, display=display.none)
signalplot = plot(signal, title="Signal", color=col_signal, display=display.none)
fill(macdplot, signalplot, topLineValue, botLineValue, topColor, botColor, title="MACD Trend Colors")
plot(bullPower + bearPower, title="BBPower Color / Columns", color=(histo>=0 ? (histo[1] < histo ? bull_grow_above : bull_fall_above) : (histo[1] < histo ? bear_grow_below : bear_fall_below)), linewidth=2, style=plot.style_columns, display=display.all)
plot(Bullma, title="Bull Void MA", color=color.rgb(29, 102, 59, 35), linewidth=2, style=plot.style_area, offset=0)
plot(Bearma, title="Bear Void MA", color=color.rgb(216, 60, 60, 35), linewidth=2, style=plot.style_area, offset=0)
//This indicator is NOT complete. Its an ongoing project and it will only get better.
//Alerts, and LONG SHORT indicators to come shortly
updated. check the main post.
 
well look whats happened here.
Hi everyone. I am CoffeeShopCrypto. the Creator of this Bull Bear Power Void volume oscillator

DO NOT GET IT CONFUSED with the MACD as it is NOT the MACD.

First.....thanks goes to @samer800 for coding this to ToS. Good job, i just hope there's nothing "missed in translation" of the code.

Just a heads up to everyone. you should NOT be using this oscillator by itself. So do not trade just because it tells you a good signal.
This is to be used in a stack with a momentum indicator.
I have created one for that too which is used in conjunction with the BBPVoid.

The benefit of the BBPVoid is that it always tells you the truth about the underlying activity which big banks and institutions can not fake in the market. If its a fakeout, youll see it with this indicator.

Benefits:
Youll be able to see actual tradable volume, not JUST volume in a direction.
Youll be able to spot false breakouts
You can use it to create volume based trendlines and see when the trend is changing
you can use it for divergences
you can use it for double divergences (yes there is a double divergence too)
You can use it immensely in FOREX where you not only need a buyer of s stock but a good trade that will move is when there is also a SELLER at that same price level of a stock.
This will show you when profits are being taken off the table (people closing positions)
It can also show you a price PUMP where you should not trade
It can show you CONTINUATION moves to stay in a trend (Volume based Break of Structure or Change of Character)

Thanks everyone
And thanks again to @samer800
 
Last edited by a moderator:
Can you please make it as MTF ?

Can anyone convert this to MTF ?
check below

CSS:
#/Bull Beear Power VOID Oscillator by @CoffeeShopCrypto
#//2022 Coded from my Kitchen and a bit from the Coffeeshop down the sreet.
#//This indicator is NOT complete. Its an ongoing project and it will only get better.
#//Alerts, and LONG SHORT indicators to come shortly
#indicator("Bull Bear Power Void", shorttitle="BBP-Void", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022
# updated the code & style Sam4Cok@Samer800 - 11/2022
# updated the signal line and added background Color - 12/2022
# update - MTF option - Sam4Cok@Samer800 - 09/2023
declare lower;
input useChartTimeframe =  {default"Yes", "No"};
input manualTimeframe   = AggregationPeriod.FIFTEEN_MIN;
input source = FundamentalType.CLOSE;
input ColorBar = yes;
input BackgroundColor = yes;
input SignalLine = yes;
input BullBearHistogram = yes;
input PowerLength = 50;
input macdType = {Default "MACD-TRADITIONAL", "MACD-AS (HISTOGRAM)", "MACD-LEADER", "MACD-SOURCE"}; #"MACD Calculation Method"
input maTypeInput = {"SMA", "EMA", "RMA", "WMA",default "VWMA", "LSMA"};
input BullBearMaType = {"SMA", default "EMA"};
input BullBearMaLength = 21;
input fast_length = 20;
input slow_length = 50;
input signal_length = 14;
input macdMaType   = {"SMA", default "EMA"};

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def macdCalc = if macdType==macdType."MACD-TRADITIONAL" then 1 else
               if macdType==macdType."MACD-AS (HISTOGRAM)" then 2 else
               if macdType==macdType."MACD-LEADER" then 3 else 4;
#-- MTF
def tf = manualTimeframe;
def HTSrc = Fundamental(source, Period = tf);
def HThi = Fundamental(FundamentalType.HIGH, Period = tf);
def HTLo = Fundamental(FundamentalType.LOW, Period = tf);
def HTCl = Fundamental(FundamentalType.CLOSE, Period = tf);
def HTVo = Fundamental(FundamentalType.VOLUME, Period = tf);
def c; def h; def l; def v;def src;
Switch (useChartTimeframe) {
case "Yes" :
    src = Fundamental(source);
    c = close;
    h = high;
    l = low;
    v = volume;
case "No"  :
    src = HTSrc;
    c = HTCl;
    h = HThi;
    l = HTLo;
    v = HTVo;
}
#vwma(source, length)
script VWMA {
    input x = close;
    input y = 21;
    input v = Volume;
    def VWMA = Average(x * v, y) / Average(v, y);
    plot result = VWMA;
}
#BullMA(source, length, type) =>
script MA {
    input source = close;
    input length = 21;
    input type = "EMA";
    input Vol = volume;
    def MA = if type == "EMA" then ExpAverage(source, length) else
             if type == "SMA" then Average(source, length) else
             if type == "WMA" then WMA(source, length) else
             if type == "RMA" then WildersAverage(source, length) else
             if type == "LSMA" then Inertia(source, length) else
             if type == "VWMA" then vwma(source, length, vol) else Double.NaN;
    plot return = MA;
}
#---- Colors.
DefineGlobalColor("BotColUp", Color.MAGENTA);
DefineGlobalColor("TopColUp", Color.CYAN);
DefineGlobalColor("noColor", CreateColor(17,17,17));
DefineGlobalColor("bull_up" , CreateColor(18, 147, 18));
DefineGlobalColor("bull_dn" , CreateColor(163,201,165));
DefineGlobalColor("bear_dn" , CreateColor(206,33,33));
DefineGlobalColor("bear_up" , Color.PINK);
DefineGlobalColor("bull" , CreateColor(115,173,118));
DefineGlobalColor("bear" , CreateColor(208,143,150));

#//Moving Average Calculations inputs and plotting//
def bullPower = h - ma(c, PowerLength,BullBearMaType, v);
def bearPower = l - ma(c, PowerLength,BullBearMaType, v);
def Bullma = MA(bullPower - bearPower, BullBearMaLength, maTypeInput, v);
def Bearma = MA(bearPower - bullPower, BullBearMaLength, maTypeInput, v);
def power = bullPower + bearPower;
def histo = power;
def hist   = if !BullBearHistogram then na else if histo>=0 then Bullma else Bearma;

#// MACD Attempt
def fastMA = MA(src, fast_length, macdMaType, v);
def slowMA = MA(src, slow_length, macdMaType, v);
def fast_ma = if macdMaType == macdMaType."SMA" then fastMA else fastMA * 10;
def slow_ma = if macdMaType == macdMaType."SMA" then slowMA else slowMA * 10;
def diff = fast_ma - slow_ma;
def macd1= if macdCalc==1 then diff else
           if macdCalc==2 then diff - ma(diff, signal_length, macdMaType, v) else
           if macdCalc==3 then diff + ma(src - fast_ma, fast_length, macdMaType, v) - ma(src - slow_ma, slow_length, macdMaType, v)
           else  ma(src - (fastMA+slowMA)/2, signal_length, macdMaType, v) * 10;
def signal1 = MA(macd1, signal_length, macdMaType);
def macd = macd1;
def signal = signal1;

#///Trend Colors to make MACD Crosses more visible
def maxLine = Bearma;
def minLine = Bullma;
def MACDBullish = macd > signal;
def topColor = if MACDBullish then 0 else 1;
def botColor = if MACDBullish then 1 else 0;
def topLineValue = if MACDBullish then maxLine else maxLine;
def botLineValue = if MACDBullish then minLine else minLine;

def color = if histo >= 0 then
            if histo[1] < histo then 2 else 1 else
            if histo[1] < histo then -1 else -2;
#///End MACD Trend Colors
#//Lets Plot everything
#//Plotting the Bull Bear Columns
plot ZeroLine = if isNaN(c) then na else 0;
ZeroLine.SetDefaultColor(Color.GRAY);
plot BBPower = histo;
BBPower.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BBPower.AssignValueColor(if color == 2 then GlobalColor("bull_up") else
                         if color == 1 then GlobalColor("bull_dn") else
                         if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));
BBPower.SetLineWeight(3);

plot bbLine = hist;
bbLine.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
bbLine.AssignValueColor(if bbLine>=0 then GlobalColor("bull") else GlobalColor("bear"));
#--- Cloud
addCloud(if BullBearHistogram then na else minLine, 0, GlobalColor("bull"));
addCloud(if BullBearHistogram then na else 0, maxLine, GlobalColor("bear"));
AddCloud(if topColor and botLineValue < signal then macd else signal,if topColor and botLineValue < signal then signal else macd , GlobalColor("BotColUp"), GlobalColor("noColor"));
AddCloud(if botColor and topLineValue > signal then signal else macd,if botColor and topLineValue > signal then macd else signal, GlobalColor("TopColUp"), GlobalColor("noColor"));

#--- Signal
def SellBar = if signal > macd and (signal<maxLine and macd<maxLine) and color<0 then SellBar[1] + 1 else 0;
def BuyBar  = if signal < macd and (signal>minLine and macd>minLine) and color>0 then BuyBar[1] + 1 else 0;

plot Bear = if !SignalLine then na else if SellBar==2 then 5 else na;
Bear.SetPaintingStrategy(PaintingStrategy.POINTS);
Bear.SetDefaultColor(Color.RED);
Bear.SetLineWeight(3);
plot bull = if !SignalLine then na else if BuyBar==2 then 5 else na;
bull.SetPaintingStrategy(PaintingStrategy.POINTS);
bull.SetDefaultColor(Color.GREEN);
bull.SetLineWeight(3);
#---- price color
AssignPriceColor(if !ColorBar then color.CURRENT else
if SellBar==2 then color.MAGENTA else
if BuyBar==2 then Color.CYAN else
if color == 2 then GlobalColor("bull_up") else
if color == 1 then GlobalColor("bull_dn") else
if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));

#--- BackGround
def volumetrend = if macd > signal and signal >= 0 then 1 else
                  if macd < signal and signal <= 0 then -1 else 0;

AddCloud(if !BackgroundColor then na else if volumetrend>0 then pos else if volumetrend<0 then neg else na, if volumetrend>0 then neg else pos, Color.DARK_GREEN, Color.DARK_RED);

#--- END CODE
 
Last edited by a moderator:
How I can set the MTF time on a 5 min chart?
default MTF is 15min in above indicator
Sure, go for it.
Change the MTF in chart settings.
Remember that you can only put the 5min MTF on timeframes of 5min or less.
 
Last edited:
check below

CSS:
#/Bull Beear Power VOID Oscillator by @CoffeeShopCrypto
#//2022 Coded from my Kitchen and a bit from the Coffeeshop down the sreet.
#//This indicator is NOT complete. Its an ongoing project and it will only get better.
#//Alerts, and LONG SHORT indicators to come shortly
#indicator("Bull Bear Power Void", shorttitle="BBP-Void", overlay=false)
# Converted by Sam4Cok@Samer800 - 11/2022
# updated the code & style Sam4Cok@Samer800 - 11/2022
# updated the signal line and added background Color - 12/2022
# update - MTF option - Sam4Cok@Samer800 - 09/2023
declare lower;
input useChartTimeframe =  {default"Yes", "No"};
input manualTimeframe   = AggregationPeriod.FIFTEEN_MIN;
input source = FundamentalType.CLOSE;
input ColorBar = yes;
input BackgroundColor = yes;
input SignalLine = yes;
input BullBearHistogram = yes;
input PowerLength = 50;
input macdType = {Default "MACD-TRADITIONAL", "MACD-AS (HISTOGRAM)", "MACD-LEADER", "MACD-SOURCE"}; #"MACD Calculation Method"
input maTypeInput = {"SMA", "EMA", "RMA", "WMA",default "VWMA", "LSMA"};
input BullBearMaType = {"SMA", default "EMA"};
input BullBearMaLength = 21;
input fast_length = 20;
input slow_length = 50;
input signal_length = 14;
input macdMaType   = {"SMA", default "EMA"};

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def macdCalc = if macdType==macdType."MACD-TRADITIONAL" then 1 else
               if macdType==macdType."MACD-AS (HISTOGRAM)" then 2 else
               if macdType==macdType."MACD-LEADER" then 3 else 4;
#-- MTF
def tf = manualTimeframe;
def HTSrc = Fundamental(source, Period = tf);
def HThi = Fundamental(FundamentalType.HIGH, Period = tf);
def HTLo = Fundamental(FundamentalType.LOW, Period = tf);
def HTCl = Fundamental(FundamentalType.CLOSE, Period = tf);
def HTVo = Fundamental(FundamentalType.VOLUME, Period = tf);
def c; def h; def l; def v;def src;
Switch (useChartTimeframe) {
case "Yes" :
    src = Fundamental(source);
    c = close;
    h = high;
    l = low;
    v = volume;
case "No"  :
    src = HTSrc;
    c = HTCl;
    h = HThi;
    l = HTLo;
    v = HTVo;
}
#vwma(source, length)
script VWMA {
    input x = close;
    input y = 21;
    input v = Volume;
    def VWMA = Average(x * v, y) / Average(v, y);
    plot result = VWMA;
}
#BullMA(source, length, type) =>
script MA {
    input source = close;
    input length = 21;
    input type = "EMA";
    input Vol = volume;
    def MA = if type == "EMA" then ExpAverage(source, length) else
             if type == "SMA" then Average(source, length) else
             if type == "WMA" then WMA(source, length) else
             if type == "RMA" then WildersAverage(source, length) else
             if type == "LSMA" then Inertia(source, length) else
             if type == "VWMA" then vwma(source, length, vol) else Double.NaN;
    plot return = MA;
}
#---- Colors.
DefineGlobalColor("BotColUp", Color.MAGENTA);
DefineGlobalColor("TopColUp", Color.CYAN);
DefineGlobalColor("noColor", CreateColor(17,17,17));
DefineGlobalColor("bull_up" , CreateColor(18, 147, 18));
DefineGlobalColor("bull_dn" , CreateColor(163,201,165));
DefineGlobalColor("bear_dn" , CreateColor(206,33,33));
DefineGlobalColor("bear_up" , Color.PINK);
DefineGlobalColor("bull" , CreateColor(115,173,118));
DefineGlobalColor("bear" , CreateColor(208,143,150));

#//Moving Average Calculations inputs and plotting//
def bullPower = h - ma(c, PowerLength,BullBearMaType, v);
def bearPower = l - ma(c, PowerLength,BullBearMaType, v);
def Bullma = MA(bullPower - bearPower, BullBearMaLength, maTypeInput, v);
def Bearma = MA(bearPower - bullPower, BullBearMaLength, maTypeInput, v);
def power = bullPower + bearPower;
def histo = power;
def hist   = if !BullBearHistogram then na else if histo>=0 then Bullma else Bearma;

#// MACD Attempt
def fastMA = MA(src, fast_length, macdMaType, v);
def slowMA = MA(src, slow_length, macdMaType, v);
def fast_ma = if macdMaType == macdMaType."SMA" then fastMA else fastMA * 10;
def slow_ma = if macdMaType == macdMaType."SMA" then slowMA else slowMA * 10;
def diff = fast_ma - slow_ma;
def macd1= if macdCalc==1 then diff else
           if macdCalc==2 then diff - ma(diff, signal_length, macdMaType, v) else
           if macdCalc==3 then diff + ma(src - fast_ma, fast_length, macdMaType, v) - ma(src - slow_ma, slow_length, macdMaType, v)
           else  ma(src - (fastMA+slowMA)/2, signal_length, macdMaType, v) * 10;
def signal1 = MA(macd1, signal_length, macdMaType);
def macd = macd1;
def signal = signal1;

#///Trend Colors to make MACD Crosses more visible
def maxLine = Bearma;
def minLine = Bullma;
def MACDBullish = macd > signal;
def topColor = if MACDBullish then 0 else 1;
def botColor = if MACDBullish then 1 else 0;
def topLineValue = if MACDBullish then maxLine else maxLine;
def botLineValue = if MACDBullish then minLine else minLine;

def color = if histo >= 0 then
            if histo[1] < histo then 2 else 1 else
            if histo[1] < histo then -1 else -2;
#///End MACD Trend Colors
#//Lets Plot everything
#//Plotting the Bull Bear Columns
plot ZeroLine = if isNaN(c) then na else 0;
ZeroLine.SetDefaultColor(Color.GRAY);
plot BBPower = histo;
BBPower.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BBPower.AssignValueColor(if color == 2 then GlobalColor("bull_up") else
                         if color == 1 then GlobalColor("bull_dn") else
                         if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));
BBPower.SetLineWeight(3);

plot bbLine = hist;
bbLine.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
bbLine.AssignValueColor(if bbLine>=0 then GlobalColor("bull") else GlobalColor("bear"));
#--- Cloud
addCloud(if BullBearHistogram then na else minLine, 0, GlobalColor("bull"));
addCloud(if BullBearHistogram then na else 0, maxLine, GlobalColor("bear"));
AddCloud(if topColor and botLineValue < signal then macd else signal,if topColor and botLineValue < signal then signal else macd , GlobalColor("BotColUp"), GlobalColor("noColor"));
AddCloud(if botColor and topLineValue > signal then signal else macd,if botColor and topLineValue > signal then macd else signal, GlobalColor("TopColUp"), GlobalColor("noColor"));

#--- Signal
def SellBar = if signal > macd and (signal<maxLine and macd<maxLine) and color<0 then SellBar[1] + 1 else 0;
def BuyBar  = if signal < macd and (signal>minLine and macd>minLine) and color>0 then BuyBar[1] + 1 else 0;

plot Bear = if !SignalLine then na else if SellBar==2 then 5 else na;
Bear.SetPaintingStrategy(PaintingStrategy.POINTS);
Bear.SetDefaultColor(Color.RED);
Bear.SetLineWeight(3);
plot bull = if !SignalLine then na else if BuyBar==2 then 5 else na;
bull.SetPaintingStrategy(PaintingStrategy.POINTS);
bull.SetDefaultColor(Color.GREEN);
bull.SetLineWeight(3);
#---- price color
AssignPriceColor(if !ColorBar then color.CURRENT else
if SellBar==2 then color.MAGENTA else
if BuyBar==2 then Color.CYAN else
if color == 2 then GlobalColor("bull_up") else
if color == 1 then GlobalColor("bull_dn") else
if color == -1 then GlobalColor("bear_up") else GlobalColor("bear_dn"));

#--- BackGround
def volumetrend = if macd > signal and signal >= 0 then 1 else
                  if macd < signal and signal <= 0 then -1 else 0;

AddCloud(if !BackgroundColor then na else if volumetrend>0 then pos else if volumetrend<0 then neg else na, if volumetrend>0 then neg else pos, Color.DARK_GREEN, Color.DARK_RED);

#--- END CODE
Hi, is there an alert for the Cyan or Magenta candle Please?
 
Last edited by a moderator:
Hi, is there an alert for the Cyan or Magenta candle Please?
add the below at the end of the code:

CSS:
input alerts   = yes;
input alertType    = Alert.BAR;
input alertSound    = Sound.NoSound;

Alert(alerts and BuyBar == 2, "Buy Signal", alertType, alertSound);
Alert(alerts and SellBar == 2, "Sell Signal", alertType, alertSound);
 
update: 10/23/23
@samer800 has updated the logic for painting the candles with this indicator.

All nine script variations in this thread have been fixed.
If you are using this indicator, download the updated code for less buggy results.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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