Profitunity - Beginner [TC]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SkyRockSignals

//@version=5
indicator("Profitunity - Beginner [TC]", overlay = true)

//INPUTS
show11and33 = input.string(defval = 'No', title ='Show (11) and (33) bars?', options = ['Yes', 'No'])
show22 = input.string(defval = 'No', title ='Show (22) bars?', options = ['Yes', 'No'])
show32and12 = input.string(defval = 'No', title ='Show (32) and (12) bars?', options = ['Yes', 'No'])
show23and21 = input.string(defval = 'No', title ='Show (23) and (21) bars?', options = ['Yes', 'No'])
show31and13 = input.string(defval = 'No', title ='Show (13) and (31) bars?', options = ['Yes', 'No'])

//SHOW BARS TYPES
doshow11and33 = show11and33 == 'Yes' ? true : false
doshow22 = show22 == 'Yes' ? true : false
doshow32and12 = show32and12 == 'Yes' ? true : false
doshow23and21 = show23and21 == 'Yes' ? true : false
doshow31and13 = show31and13 == 'Yes' ? true : false


//BARS TYPE DEFINITION
bar11 = close > high - (high - low)/3 and open > high - (high - low)/3   
bar22 = close < high - (high - low)/3 and close > high - (2*(high - low))/3 and open < high - (high - low)/3 and open > high - (2*(high - low))/3
bar33 = close < high - (2*(high - low))/3 and open < high - 2*(high - low)/3    
bar13 = open > high - (high - low)/3 and close < high - (2*(high - low))/3
bar31 = open < high - (2*(high - low))/3 and close > high - (high - low)/3 
bar21 = open < high - (high - low)/3 and open >  high - (2*(high - low))/3 and close > high - (high - low)/3 
bar32 = open < high - (2*(high - low))/3 and close < high - (high - low)/3 and close > high - (2*(high - low))/3
bar23 = open < high - (high - low)/3 and open >  high - (2*(high - low))/3 and close < high - (2*(high - low))/3
bar12 = open > high - (high - low)/3 and close < high - (high - low)/3 and close >  high - (2*(high - low))/3 

//TREND MARKERS
downtrend_marker = (high + low)/2 < low[1]
uptrend_marker = (high + low)/2 > high[1]


//TOTAL VOLUME
usdt_total_volume = nz(request.security("BINANCE:BTCUSDT", "D", volume))+nz(request.security("KUCOIN:BTCUSDT", "D", volume))+nz(request.security("BINGX:BTCUSDT", "D", volume))+nz(request.security("OKX:BTCUSDT", "D", volume))+nz(request.security("HUOBI:BTCUSDT", "D", volume))+nz(request.security("FTX:BTCUSDT", "D", volume/close))+nz(request.security("COINBASE:BTCUSDT", "D", volume))+nz(request.security("PHEMEX:BTCUSDT", "D", volume))+nz(request.security("BINANCEUS:BTCUSDT", "D", volume))+nz(request.security("BITGET:BTCUSDT", "D", volume))+nz(request.security("BITTREX:BTCUSDT", "D", volume))+nz(request.security("GATEIO:BTCUSDT", "D", volume))+nz(request.security("POLONIEX:BTCUSDT", "D", volume))+nz(request.security("MEXC:BTCUSDT", "D", volume))+nz(request.security("BITSTAMP:BTCUSDT", "D", volume))+nz(request.security("KRAKEN:BTCUSDT", "D", volume))+nz(request.security("OKCOIN:BTCUSDT", "D", volume))+nz(request.security("CURRENCYCOM:BTCUSDT", "D", volume))+nz(request.security("WHITEBIT:BTCUSDT", "D", volume))+nz(request.security("ASCENDEX:BTCUSDT", "D", volume))+nz(request.security("TIMEX:BTCUSDT", "D", volume))+nz(request.security("UPBIT:BTCUSDT", "D", volume))+nz(request.security("EXMO:BTCUSDT", "D", volume))+nz(request.security("DELTA:BTCUSDT", "D", volume))+nz(request.security("WOONETWORK:BTCUSDT", "D", volume))

usdc_total_volume = nz(request.security("BINANCE:BTCUSDC", "D", volume))+nz(request.security("KUCOIN:BTCUSDC", "D", volume))+nz(request.security("BITSTAMP:BTCUSDC", "D", volume))+nz(request.security("COINBASE:BTCUSDC", "D", volume))+nz(request.security("KRAKEN:BTCUSDC", "D", volume))+nz(request.security("POLONIEX:BTCUSDC", "D", volume))+nz(request.security("BITTREX:BTCUSDC", "D", volume))+nz(request.security("BINGX:BTCUSDC", "D", volume))+nz(request.security("OKX:BTCUSDC", "D", volume))+nz(request.security("HUOBI:BTCUSDC", "D", volume))+nz(request.security("PHEMEX:BTCUSDC", "D", volume))+nz(request.security("BINANCEUS:BTCUSDC", "D", volume))+nz(request.security("BITGET:BTCUSDC", "D", volume))+nz(request.security("WHITEBIT:BTCUSDC", "D", volume))+nz(request.security("WOONETWORK:BTCUSDC", "D", volume))

total_volume = usdt_total_volume + usdc_total_volume
//MFI AND PROFITUNITY WINDOWS
MFI = (high - low)/volume
squat = MFI < MFI[1] and volume > volume[1]
green = MFI > MFI[1] and volume > volume[1] 
fade = MFI < MFI[1] and volume < volume[1]
fake = MFI > MFI[1] and volume < volume[1]

//PLOT THE UPTREND BAR LABELS
plotshape(uptrend_marker and doshow11and33 and bar11?true: na,text="11",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(uptrend_marker and doshow22 and bar22?true: na,text="22",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(uptrend_marker and doshow11and33 and bar33?true: na,text="33",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(uptrend_marker and doshow31and13 and bar13?true: na,text="13",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(uptrend_marker and doshow31and13 and bar31?true: na,text="31",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(uptrend_marker and doshow23and21 and bar21?true: na,text="21",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(uptrend_marker and doshow32and12 and bar32?true: na,text="32",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(uptrend_marker and doshow23and21 and bar23?true: na,text="23",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(uptrend_marker and doshow32and12 and bar12?true: na,text="12",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar)

//PLOT THE DOWNTREND BAR LABELS
plotshape(downtrend_marker and doshow11and33 and bar11?true: na,text="11",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(downtrend_marker and doshow22 and bar22?true: na,text="22",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(downtrend_marker and doshow11and33 and bar33?true: na,text="33",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(downtrend_marker and doshow31and13 and bar13?true: na,text="13",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(downtrend_marker and doshow31and13 and bar31?true: na,text="31",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(downtrend_marker and doshow23and21 and bar21?true: na,text="21",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(downtrend_marker and doshow32and12 and bar32?true: na,text="32",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(downtrend_marker and doshow23and21 and bar23?true: na,text="23",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(downtrend_marker and doshow32and12 and bar12?true: na,text="12",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar)

//PLOT NO TREND BAR LABELS
plotshape(not(uptrend_marker or downtrend_marker) and doshow11and33 and bar11?true: na,text="11",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(not(uptrend_marker or downtrend_marker) and doshow22 and bar22?true: na,text="22",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(not(uptrend_marker or downtrend_marker) and doshow11and33 and bar33?true: na,text="33",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(not(uptrend_marker or downtrend_marker) and doshow31and13 and bar13?true: na,text="13",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(not(uptrend_marker or downtrend_marker) and doshow31and13 and bar31?true: na,text="31",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(not(uptrend_marker or downtrend_marker) and doshow23and21 and bar21?true: na,text="21",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(not(uptrend_marker or downtrend_marker) and doshow32and12 and bar32?true: na,text="32",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(not(uptrend_marker or downtrend_marker) and doshow23and21 and bar23?true: na,text="23",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar)
plotshape(not(uptrend_marker or downtrend_marker) and doshow32and12 and bar12?true: na,text="12",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar)

//BARS COLORING ACCORDING TO SQUAT, GREEN, FASE AND FAKE 
barcolor(green? color.green : na)
barcolor(squat?color.red : na)
//barcolor(fade?color.yellow: na)
//barcolor(fake?color.blue: na)

//SIGNALS
plotshape(downtrend_marker and squat and bar13?true: na,text="STRONG LONG",size=size.tiny, offset=0,color=color.green,textcolor=color.green,style=shape.triangleup,location=location.belowbar)
plotshape(uptrend_marker and squat and bar31?true: na,text="STRONG SHORT",size=size.tiny, offset=0,color=color.red,textcolor=color.red,style=shape.triangledown,location=location.abovebar)

//plotshape(squat and bar11?true: na,text="LONG",size=size.tiny, offset=0,color=color.green,textcolor=color.green,style=shape.triangleup,location=location.belowbar)
//plotshape(squat and bar33?true: na,text="SHORT",size=size.tiny, offset=0,color=color.red,textcolor=color.red,style=shape.triangledown,location=location.abovebar)