Price Volume Rank [LazyBear]

Price-Volume Rank, designed by Anthony J. Macek, compares the direction of the change in price (up or down) to the direction of the change in volume and assigns a number to that specific relationship. By quantifying price/ volume interaction, P-V rank seeks to determine our position within a typical market cycle.

The various modes shown on the chart above or explained below. Also, read on for a little trick using the new Pine feature that you can use in your script.

How to read the PVR?
The most desirable market condition occurs when both price and volume are moving up, that phenomenon is assigned a PVR of 1.

The next most desirable condition, when prices are still moving up but volume is diminishing, is given a PVR of 2. Although still technically healthy, this relationship between price and volume issues a warning that market momentum is weakening.

The worst-case scenario, seen when selling pressure is greatest with prices dropping and volume
increasing, is given PVR's weakest designation, 4.

Finally, even though prices are still moving down, volume begins to diminish as selling pressure abates. This price/ volume relationship is assigned a PVR of 3, often alerting us to a potential buying opportunity ahead.

What do the modes mean?

1) Histogram Mode: This plots PVR along with helpful ranges. Be careful when PVR is trending at turn-around points.
2) MA Crossover Mode: This plots a slow/fast MA of PVR . Default is 5/10 SMA . Buy is signalled when slow MA falls below fast MA. Sell is signalled when slow MA crosses up fast MA. There is a warning line at 2.5 that can be used for more confirmation.
3) Double Smoothed Crossover Mode: Same as MA crossover, but PVR is smoothed more. Warning line (2.5 level) is very useful in this mode. Use slow MA as the signal and fast MA of PVR for tracking the market.

Misc notes:
This won't work for Forex and other instruments for which TradingView doesn't expose volume . Thanks to the new Text rendering feature of PlotShape(), I can actually let users know of that :) Good use-case, eh? I will post a sample chart below in the comments.

Feel free to use any part of this code in your indicators.

More info:
Stocks & Commodities V. 12:6 (235-239): Price-Volume Rank by Anthony J. Macek

Complete list of my indicators:

List of my free indicators:
List of my indicators at Appstore:

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎของบ้าน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้


ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

// @author LazyBear 
// List of all my indicators: 
study("Price Volume Rank [LazyBear]", shorttitle="PVR_LB", overlay=false)
showMA=input(true, title="Show MA Crossovers")
ma1=input(5, title="Fast MA Length", defval=5),ma2=input(10, title="Slow MA Length", defval=10)
dblSmoothing=input(false, title="Double Smoothing")
pvr=iff(close>close[1] and volume>volume[1],1,
	iff(close>close[1] and volume<=volume[1],2,
	iff(close<=close[1] and volume<=volume[1],3,4)))
u=plot(showMA?na:na(volume)?na:2.0, color=green, title="BullLine")
l=plot(showMA?na:na(volume)?na:3.0, color=red, title="BearLine")
mal=plot(showMA?na(volume)?na:2.5:na, color=gray, title="MACutoff")
plot(showMA?na:na(volume)?na:pvr, style=histogram, histbase=2, color=pvr>3.0?red:pvr<2.0?green:gray, linewidth=2,transp=40, title="PVR")
plot(showMA?na:na(volume)?na:pvr, style=circles, color=pvr>=3.0?red:pvr<=2.0?green:gray, linewidth=4, title="PVR Points")
sma1=not showMA?na:dblSmoothing?sma(sma(pvr,ma1),ma1):sma(pvr,ma1), sma2=not showMA?na:dblSmoothing?sma(sma(pvr,ma2),ma2):sma(pvr,ma2)
plot(showMA?na(volume)?na:sma1:na, style=linebr, color=red, linewidth=2, title="Fast MA")
plot(showMA?na(volume)?na:sma2:na, style=linebr, color=green, linewidth=1, title="Slow MA")
plotshape(na(volume)?x:na,, color=red, text="No volume", location=location.absolute, title="ErrorText")