- Platform
-
- Thinkorswim
Code:
# Converted to TOS from Siyeon's Tradingview "Volume Based Buy and Sell Momentum by 2tm" indicator by NPtechs
declare lower;
input ma_length = 25;
def xROC = (close - close[1]) * 100 / close;
def nRes1 = if (volume < volume[1]) then
nRes1[1] + xROC
else
nRes1[1];
def nRes2 = if (volume > volume[1]) then
nRes2[1] + xROC
else
nRes2[1];
def nRes3 = nRes1 + nRes2;
def nResEMA3 = simpleMovingAvg(nRes1, ma_length) + simpleMovingAvg(nRes2, ma_length);
plot PNVI = nRes3;
plot PEMA = nResEMA3;
input PaintBars = Yes;
AssignPriceColor (if !PaintBars then Color.CURRENT else if PNVI > PEMA then Color.GREEN else Color.RED);
PNVI.SetDefaultColor(GetColor(1));
PNVI.DefineColor("Up Momentum", Color.BLUE);
PNVI.AssignValueColor(PNVI.color("Up Momentum"));
PEMA.SetDefaultColor(GetColor(1));
PEMA.DefineColor("Down Momentum", Color.RED);
PEMA.AssignValueColor(PEMA.color("Down Momentum"));
AddCloud(PNVI,PEMA,PNVI.color("Up Momentum"),PEMA.color("Down Momentum"));