Candle relative power
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AliSignals

//@version=5
indicator("Candle relative power", timeframe="")
Length = input.int(1)
Shadowindex = input.float(0.5, title= "Shadow index")
AverageCriteria = input.int(24, title= "Average Criteria")

// Calculating Close, Open, High and Low of the integrated candles
CO = close-open[Length]
H = ta.highest(high,Length)
L = ta.lowest(low,Length)

// Calculating Highest and Lowest of closes and opens of the integrated candles
maxC = ta.highest(close,Length)
maxO = ta.highest(open,Length)
minC = ta.lowest(close,Length)
minO = ta.lowest(open,Length)
maxCO = math.max(maxC,maxO)
minCO = math.min(minC,minO)

//calculating TR of of the integrated candles 
HL = H-L
HC = math.abs(H-close[Length])
LC = math.abs(L-close[Length])
TR = math.max(HL,HC,LC)
ATR = ta.sma(TR,AverageCriteria*Length)


// Calculating shadows
TSH = H-maxCO
BSH = minCO-L

// Calculating candle power
CP = (CO+BSH-TSH)/ATR
V = math.sum(volume,Length)
VP = CP*V/ta.sma(V,AverageCriteria*Length)


plot(CP, title= "CP")
plot(VP, color=color.yellow, title= "VP")
hline(3)
hline(-3)


