// Buy vs Sell power X
//
// https://www.tradingview.com/script/XZ3UXRvL-buy-vs-sell-power-x/
//
ONCE pt = 0
ONCE s = 5
ONCE m = 9
ONCE l = 14
HiLow = ((high - low) * 100)
OpenClose = ((close - open) * 100)
VolX = (close / HiLow)
SpreadV = (OpenClose * close)
pt = SpreadV + pt
a = Average[l,1](pt) - Average[m,1](pt)
b = Average[s,1](pt) - Average[m,1](pt)
p = a + b
bullishRule = (b > p) //original (b >= p)
bearishRule = (b < p) //original (b <= p)
//ruleState = 0 //not used
IF bullishRule THEN
//ruleState= 1 //not used
BackGroundColor(0,0,255,70) //BLUE background (70 can be changed to any value between 0 and 255, 0=invisible, 255=plain)
ELSIF bearishRule THEN
//ruleState= -1 //not used
BackGroundColor(255,0,0,70) //RED background (70 can be changed to any value between 0 and 255, 0=invisible, 255=plain)
ENDIF
RETURN a AS "a",p AS "p"