ShirokiHeishi

Klinger Volume Price Trend combo (page2)

I forgot to mention
Sorry,
Thanks to Vdub for the great idea of coding in nadex volume
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//This can be used with any security that volume data is generated for.  The inputs are self-exlanitory.  If it is a Forex
//symbol, then leave the Forex box checked (you must use time frame less than daily though).  This simple volume tool generates 
//a signal by color change as follows:If the KVO is positive and you see a green candle develope go long on the high, if the KVO is 
//negative and a red candle develops, go short on the low of the candle.  The order is important, KVO first then PVT color bar, it 
//is ok if they both happen on the same candle. When you choose to not detrend the PVT data you can see the volume trend as a cumulative
//total.  I like its oscillator look as a detrend indicator though.  I use this with Ichimoku cloud to show resistance, stop loss levels and targets.
//By setting the detrend period of the Price Volume Trend indicator (PVT) to 156, you can sneek a peek at daily forex volumes, but
//otherwise, feel free to change the settings to whatever works for you.  The Klinger oscillator (KVO) seems largely best with its 
//original settings of 55 34 13.  When you turn off the KVO signal you can see the last crossover date and its high or low price.  They are
//color coded red for a bearish zero crossover and green for bullish.  Unfortunately, if you don't want to see all the excess plot lines, you
//have to uncheck all the plots for the indicator dates and prices...but what the heck.
//                                          -ShirokiHeishi
study(title="Klinger Volume Price Trend combo", shorttitle="PVKc 2.2")
choice2 = input(false, title="PVT or KVO")
f = input (true, title="forex?") 
fxpairs =
      ticker == "XPDUSD" ? "FX_IDC:XPDUSD" :
      ticker == "XPTUSD" ? "FX_IDC:XPTUSD" :
      ticker == "GBPJPY" ? "FX_IDC:GBPJPY" :
	  ticker == "EURUSD" ? "FX_IDC:EURUSD" : 
	  ticker == "AUDCAD" ? "FX_IDC:AUDCAD" : 
	  ticker == "AUDCHF" ? "FX_IDC:AUDCHF" : 
	  ticker == "AUDJPY" ? "FX_IDC:AUDJPY" : 
	  ticker == "AUDNZD" ? "FX_IDC:AUDNZD" : 
	  ticker == "CADCHF" ? "FX_IDC:CADCHF" : 
	  ticker == "EURAUD" ? "FX_IDC:EURAUD" : 
	  ticker == "EURCAD" ? "FX_IDC:EURCAD" : 
	  ticker == "EURCHF" ? "FX_IDC:EURCHF" : 
	  ticker == "EURGBP" ? "FX_IDC:EURGBP" : 
	  ticker == "EURJPY" ? "FX_IDC:EURJPY" : 
	  ticker == "EURNOK" ? "FX_IDC:EURNOK" : 
	  ticker == "EURNZD" ? "FX_IDC:EURNZD" : 
	  ticker == "EURSEK" ? "FX_IDC:EURSEK" : 
	  ticker == "EURTRY" ? "FX_IDC:EURTRY" : 
	  ticker == "GBPAUD" ? "FX_IDC:GBPAUD" : 
	  ticker == "GBPCAD" ? "FX_IDC:GBPCAD" :  
	  ticker == "GBPUSD" ? "FX_IDC:GBPUSD" : 
	  ticker == "NZDCAD" ? "FX_IDC:NZDCAD" : 
	  ticker == "NZDCHF" ? "FX_IDC:NZDCHF" : 
	  ticker == "NZDJPY" ? "FX_IDC:NZDJPY" : 
	  ticker == "NZDUSD" ? "FX_IDC:NZDUSD" : 
	  ticker == "TRYJPY" ? "FX_IDC:TRYJPY" : 
	  ticker == "USDAED" ? "FX_IDC:USDAED" :
	  ticker == "USDAFN" ? "FX_IDC:USDAFN" :
	  ticker == "USDALL" ? "FX_IDC:USDALL" :
	  ticker == "USDAMD" ? "FX_IDC:USDAMD" :
	  ticker == "USDANG" ? "FX_IDC:USDANG" :
	  ticker == "USDAOA" ? "FX_IDC:USDAOA" :
	  ticker == "USDARS" ? "FX_IDC:USDARS" :
	  ticker == "AUDUSD" ? "FX_IDC:AUDUSD" :
	  ticker == "USDAWG" ? "FX_IDC:USDAWG" :
	  ticker == "USDAZN" ? "FX_IDC:USDAZN" :
	  ticker == "USDBBD" ? "FX_IDC:USDBBD" :
	  ticker == "USDBDT" ? "FX_IDC:USDBDT" :
	  ticker == "USDBGN" ? "FX_IDC:USDBGN" :
	  ticker == "USDBHD" ? "FX_IDC:USDBHD" :
	  ticker == "USDBIF" ? "FX_IDC:USDBIF" :
	  ticker == "USDBMD" ? "FX_IDC:USDBMD" :
	  ticker == "USDBND" ? "FX_IDC:USDBND" :
	  ticker == "USDBOB" ? "FX_IDC:USDBOB" :
	  ticker == "USDBRL" ? "FX_IDC:USDBRL" :
	  ticker == "USDBSD" ? "FX_IDC:USDBSD" :
	  ticker == "USDBTN" ? "FX_IDC:USDBTN" :
	  ticker == "USDBWP" ? "FX_IDC:USDBWP" :
	  ticker == "USDBYR" ? "FX_IDC:USDBYR" :
	  ticker == "USDBZD" ? "FX_IDC:USDBZD" :
	  ticker == "USDCAD" ? "FX_IDC:USDCAD" :
	  ticker == "USDCAX" ? "FX_IDC:USDCAX" :
	  ticker == "USDCDF" ? "FX_IDC:USDCDF" :
	  ticker == "USDCHF" ? "FX_IDC:USDCHF" :
	  ticker == "USDCLF" ? "FX_IDC:USDCLF" :
	  ticker == "USDCLP" ? "FX_IDC:USDCLP" :
	  ticker == "USDCNY" ? "FX_IDC:USDCNY" :
	  ticker == "USDCOP" ? "FX_IDC:USDCOP" :
	  ticker == "USDCRC" ? "FX_IDC:USDCRC" :
	  ticker == "USDCUP" ? "FX_IDC:USDCUP" :
	  ticker == "USDCVE" ? "FX_IDC:USDCVE" :
	  ticker == "USDCZK" ? "FX_IDC:USDCZK" :
	  ticker == "USDDJF" ? "FX_IDC:USDDJF" :
	  ticker == "USDDKK" ? "FX_IDC:USDDKK" :
	  ticker == "USDDOP" ? "FX_IDC:USDDOP" :
	  ticker == "USDDZD" ? "FX_IDC:USDDZD" :
	  ticker == "USDEGP" ? "FX_IDC:USDEGP" :
	  ticker == "USDERN" ? "FX_IDC:USDERN" :
	  ticker == "USDETB" ? "FX_IDC:USDETB" :
	  ticker == "USDEUR" ? "FX_IDC:USDEUR" :
	  ticker == "USDFJD" ? "FX_IDC:USDFJD" :
	  ticker == "USDFKP" ? "FX_IDC:USDFKP" :
	  ticker == "USDGBP" ? "FX_IDC:USDGBP" :
	  ticker == "USDGEL" ? "FX_IDC:USDGEL" :
	  ticker == "USDGHS" ? "FX_IDC:USDGHS" :
	  ticker == "USDGIP" ? "FX_IDC:USDGIP" :
	  ticker == "USDGMD" ? "FX_IDC:USDGMD" :
	  ticker == "USDGNF" ? "FX_IDC:USDGNF" :
	  ticker == "USDGTQ" ? "FX_IDC:USDGTQ" :
	  ticker == "USDGYD" ? "FX_IDC:USDGYD" :
	  ticker == "USDHKD" ? "FX_IDC:USDHKD" :
	  ticker == "USDHNL" ? "FX_IDC:USDHNL" :
	  ticker == "USDHRK" ? "FX_IDC:USDHRK" :
	  ticker == "USDHTG" ? "FX_IDC:USDHTG" :
	  ticker == "USDHUF" ? "FX_IDC:USDHUF" :
	  ticker == "USDIDR" ? "FX_IDC:USDIDR" :
	  ticker == "USDILS" ? "FX_IDC:USDILS" :
	  ticker == "USDINR" ? "FX_IDC:USDINR" :
	  ticker == "USDIQD" ? "FX_IDC:USDIQD" :
	  ticker == "USDIRR" ? "FX_IDC:USDIRR" :
	  ticker == "USDISK" ? "FX_IDC:USDISK" :
	  ticker == "USDJMD" ? "FX_IDC:USDJMD" :
	  ticker == "USDJOD" ? "FX_IDC:USDJOD" :
	  ticker == "USDJPY" ? "FX_IDC:USDJPY" :
	  ticker == "USDKES" ? "FX_IDC:USDKES" :
	  ticker == "USDKGS" ? "FX_IDC:USDKGS" :
	  ticker == "USDKHR" ? "FX_IDC:USDKHR" :
	  ticker == "USDKMF" ? "FX_IDC:USDKMF" :
	  ticker == "USDKPW" ? "FX_IDC:USDKPW" :
	  ticker == "USDKRW" ? "FX_IDC:USDKRW" :
	  ticker == "USDKWD" ? "FX_IDC:USDKWD" :
	  ticker == "USDKYD" ? "FX_IDC:USDKYD" :
	  ticker == "USDKZT" ? "FX_IDC:USDKZT" :
	  ticker == "USDLAK" ? "FX_IDC:USDLAK" :
	  ticker == "USDLBP" ? "FX_IDC:USDLBP" :
	  ticker == "USDLKR" ? "FX_IDC:USDLKR" :
	  ticker == "USDLRD" ? "FX_IDC:USDLRD" :
	  ticker == "USDLSL" ? "FX_IDC:USDLSL" :
	  ticker == "USDLTL" ? "FX_IDC:USDLTL" :
	  ticker == "USDLVL" ? "FX_IDC:USDLVL" :
	  ticker == "USDLYD" ? "FX_IDC:USDLYD" :
	  ticker == "USDMAD" ? "FX_IDC:USDMAD" :
	  ticker == "USDMDL" ? "FX_IDC:USDMDL" :
	  ticker == "USDMGA" ? "FX_IDC:USDMGA" :
	  ticker == "USDMKD" ? "FX_IDC:USDMKD" :
	  ticker == "USDMMK" ? "FX_IDC:USDMMK" :
	  ticker == "USDMNT" ? "FX_IDC:USDMNT" :
	  ticker == "USDMOP" ? "FX_IDC:USDMOP" :
	  ticker == "USDMRO" ? "FX_IDC:USDMRO" :
	  ticker == "USDMUR" ? "FX_IDC:USDMUR" :
	  ticker == "USDMVR" ? "FX_IDC:USDMVR" :
	  ticker == "USDMWK" ? "FX_IDC:USDMWK" :
	  ticker == "USDMXN" ? "FX_IDC:USDMXN" :
	  ticker == "USDMXV" ? "FX_IDC:USDMXV" :
	  ticker == "USDMYR" ? "FX_IDC:USDMYR" :
	  ticker == "USDMZN" ? "FX_IDC:USDMZN" :
	  ticker == "USDNAD" ? "FX_IDC:USDNAD" :
	  ticker == "USDNGN" ? "FX_IDC:USDNGN" :
	  ticker == "USDNIO" ? "FX_IDC:USDNIO" :
	  ticker == "USDNOK" ? "FX_IDC:USDNOK" :
	  ticker == "USDNPR" ? "FX_IDC:USDNPR" :
	  ticker == "USDNZD" ? "FX_IDC:USDNZD" :
	  ticker == "USDOMR" ? "FX_IDC:USDOMR" :
	  ticker == "USDPAB" ? "FX_IDC:USDPAB" :
	  ticker == "USDPEN" ? "FX_IDC:USDPEN" :
	  ticker == "USDPGK" ? "FX_IDC:USDPGK" :
	  ticker == "USDPHP" ? "FX_IDC:USDPHP" :
	  ticker == "USDPKR" ? "FX_IDC:USDPKR" :
	  ticker == "USDPLN" ? "FX_IDC:USDPLN" :
	  ticker == "USDPLX" ? "FX_IDC:USDPLX" :
	  ticker == "USDPYG" ? "FX_IDC:USDPYG" :
	  ticker == "USDQAR" ? "FX_IDC:USDQAR" :
	  ticker == "USDRON" ? "FX_IDC:USDRON" :
	  ticker == "USDRSD" ? "FX_IDC:USDRSD" :
	  ticker == "USDRUB" ? "FX_IDC:USDRUB" :
	  ticker == "USDRWF" ? "FX_IDC:USDRWF" :
	  ticker == "USDSAR" ? "FX_IDC:USDSAR" :
	  ticker == "USDSBD" ? "FX_IDC:USDSBD" :
	  ticker == "USDSCR" ? "FX_IDC:USDSCR" :
	  ticker == "USDSDG" ? "FX_IDC:USDSDG" :
	  ticker == "USDSEK" ? "FX_IDC:USDSEK" :
	  ticker == "USDSGD" ? "FX_IDC:USDSGD" :
	  ticker == "USDSHP" ? "FX_IDC:USDSHP" :
	  ticker == "USDSLL" ? "FX_IDC:USDSLL" :
	  ticker == "USDSOS" ? "FX_IDC:USDSOS" :
	  ticker == "USDSRD" ? "FX_IDC:USDSRD" :
	  ticker == "USDSTD" ? "FX_IDC:USDSTD" :
	  ticker == "USDSVC" ? "FX_IDC:USDSVC" :
	  ticker == "USDSYP" ? "FX_IDC:USDSYP" :
	  ticker == "USDSZL" ? "FX_IDC:USDSZL" :
	  ticker == "USDTHB" ? "FX_IDC:USDTHB" :
	  ticker == "USDTJS" ? "FX_IDC:USDTJS" :
	  ticker == "USDTMT" ? "FX_IDC:USDTMT" :
	  ticker == "USDTND" ? "FX_IDC:USDTND" :
	  ticker == "USDTOP" ? "FX_IDC:USDTOP" :
	  ticker == "USDTRY" ? "FX_IDC:USDTRY" :
	  ticker == "USDTTD" ? "FX_IDC:USDTTD" :
	  ticker == "USDTWD" ? "FX_IDC:USDTWD" :
	  ticker == "USDTZS" ? "FX_IDC:USDTZS" :
	  ticker == "USDUAH" ? "FX_IDC:USDUAH" :
	  ticker == "USDUGX" ? "FX_IDC:USDUGX" :
	  ticker == "USDUYU" ? "FX_IDC:USDUYU" :
	  ticker == "USDUZS" ? "FX_IDC:USDUZS" :
	  ticker == "USDVEF" ? "FX_IDC:USDVEF" :
	  ticker == "USDVND" ? "FX_IDC:USDVND" :
	  ticker == "USDVUV" ? "FX_IDC:USDVUV" :
	  ticker == "USDWST" ? "FX_IDC:USDWST" :
	  ticker == "USDXAF" ? "FX_IDC:USDXAF" :
	  ticker == "USDXCD" ? "FX_IDC:USDXCD" :
	  ticker == "USDXCU" ? "FX_IDC:USDXCU" :
	  ticker == "USDXDR" ? "FX_IDC:USDXDR" :
	  ticker == "USDXOF" ? "FX_IDC:USDXOF" :
	  ticker == "USDXPF" ? "FX_IDC:USDXPF" :
	  ticker == "USDYER" ? "FX_IDC:USDYER" :
	  ticker == "USDZAR" ? "FX_IDC:USDZAR" :
	  ticker == "USDZWL" ? "FX_IDC:USDZWL" :
	  ticker == "ZARJPY" ? "FX_IDC:ZARJPY" :
	  ticker == "XAGUSD" ? "FX_IDC:XAGUSD" :
	  ticker == "XAUUSD" ? "FX_IDC:XAUUSD" :
	  "                                  "
//----------------------------------------------------------------------------//
tick = input(false, title="Unknown symbol?")
sec = input("XAGUSD", type=symbol, title="Symbol Input")
KVOslow = input (55)
KVOfast = input (34)
Signal  = input (13)
src = security(f?fxpairs:tick==true?sec:ticker, period, volume, false)
sv = change(hlc3) >= 0 ? src : -src
kvo = ema(sv, KVOfast) - ema(sv, KVOslow)
sig = ema(kvo, Signal)
diff = (kvo - sig)
plot(choice2==false?kvo/10000:na, color=maroon, transp=0, title='KVO')
plot(choice2==false?sig/10000:na, color = black, title='Signal line' , style=line, linewidth = 1, transp=0)
hline(0, color=#656565, linestyle=dotted)

src4 = security(f==true?fxpairs:tick==true?sec:ticker, period, volume, false) 
src2 = close
choice = input(true, title="detrended?")
vt = cum(change(src2)/src2[1]*src)
x = input(26, title= "detrend period")
y =  ((x/2) + 1)
z = vt - sma(vt, y)
pvtvalue1 = barssince(z>0 and z[1]<=0)+1
pvtvalue2 = barssince(z<0 and z[1]>=0)+1
pvtvalue3 = valuewhen(pvtvalue1==1,high,0)
pvtvalue4 = valuewhen(pvtvalue2==1,low,0)
plot(choice2==true and choice?z:choice2==true and choice==false?vt:na, color=maroon, title="PVT",style= line, linewidth=1, transp=0)
plot (choice==true and choice2==true?0:na, color=#656565, transp=0)
plot(choice2==true?pvtvalue3:na, color=lime, transp=0, title='High on crossover')
plot(choice2==true?pvtvalue1:na, color=green, transp=0, title='Bars since bullish signal')
plot(choice2==true?pvtvalue4:na, color=red, transp=0, title="Low on crossover")
plot(choice2==true?pvtvalue2:na, color=maroon, transp=0, title="Bars since bearish signal")
showcolor=input(true, title='Show color bars?')
barcolor(showcolor==true and z>0?lime:showcolor==true and z<0?red:na)