Help porting Volume Impact indicator to ToS

Risto Benji

New member
Hey guys, not new to the site but just registered. This site has been a great resource as I have been lurking, much thanks to those who contribute to its success. As the title suggests, I'm wondering if anyone with knowledge of Tradingview code can port this indicator...... Thanks in advance.

Code:
//Written by Umur Ozkul
//@version=3
study(title="Volume Impact", shorttitle="UO_VI")
TrigLen = input(7, minval=1)
FastX = input(34, minval=1)
SlowX = input(55, minval=1)
hline(0, color=gray, linestyle=line)
xTrend = iff(hlc3 > hlc3[1], volume * 100, -volume * 100)
xFast = ema(xTrend, FastX)
xSlow = ema(xTrend, SlowX)
xKVO = xFast - xSlow
xTrigger = ema(xKVO, TrigLen)

p = close - close[1]
pTrigger = ema(p, TrigLen)

volumeImpact = (xKVO - xTrigger)*1.2

buyColor=green
sellColor=red

xDirection = xTrigger - xTrigger[1]
pDirection = pTrigger - pTrigger[1]

buyit=1
sellit=-1
donothing=0

suggestion = (volumeImpact - volumeImpact[1]) > 0 ? buyit : sellit

paint=suggestion
impactColor= paint==buyit ? green : paint==sellit ? red : gray
plot(volumeImpact, color=impactColor, style=area, title="KVO")

triggerColor = xTrigger>=0 ? green : red
plot(xTrigger, linewidth=4, color=triggerColor, title="Trigger")

//barColor
//triggerColor
kvoColor = xKVO >= 0 ? green : red
impactFlipColor = volumeImpact >= 0 ? green : red

plot(xKVO, title="KVO")
priceColorOpt = input(title="Bar Color", defval="Impact>0", options=["Default", "KVO,Impact Direction", "Impact>0", "Trigger>0", "KVO>0"])
priceColor0 = priceColorOpt == "Default" ? na : priceColorOpt == "KVO,Impact Direction" ? impactColor :  priceColorOpt=="Impact>0"? impactFlipColor : priceColorOpt == "Trigger>0" ? triggerColor : kvoColor
priceColor = priceColor0 == green ? lime : orange
//priceColor = close > open and priceColor0 == green or close < open and priceColor0 == red ? priceColor1 : na

barcolor(priceColor)

Link to the indicator details
 
Last edited by a moderator:

BenTen

Administrative
Staff
VIP
@Risto Benji @JohnsonM Rough conversion but should be the same as the one from TradingView.

Code:
# Volume Impact
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/CBUdx2Wo-Volume-Impact/

declare lower;

input TrigLen = 7;
input FastX = 34;
input SlowX = 55;

def xTrend = if(hlc3 > hlc3[1], volume* 100, -volume* 100);
def xFast = expAverage(xTrend, FastX);
def xSlow = expAverage(xTrend, SlowX);
def xKVO = xFast - xSlow;
def xTrigger = expAverage(xKVO, TrigLen);

def p = close - close[1];
def pTrigger = expAverage(p, TrigLen);

def volumeImpact = (xKVO - xTrigger) * 1.2;

def xDirection = xTrigger - xTrigger[1];
def pDirection = pTrigger - pTrigger[1];

def buyit = 1;
def sellit = -1;

def suggestion = if (volumeImpact - volumeImpact[1]) > 0 then buyit else sellit;

def paint = suggestion;

plot KVO = volumeImpact;
KVO.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
KVO.AssignValueColor(if paint == buyit then color.green else if paint == sellit then color.red else color.gray);
plot Trigger = xTrigger;
Trigger.AssignValueColor(if xTrigger>=0 then color.green else color.red);
plot c = xKVO;
c.AssignValueColor(color.CYAN);
 

zeek

Active member
2019 Donor
Looks interesting. Can this study be modified so that it only shows the buy/sell signals as arrows on the chart instead of using the lower study? @BenTen
 

Similar threads

Top