tradearcher

Trade Archer - On balance Volume Moving Averages - v1

This indicator improves upon the normal OBV indicator by including Moving Averages of OBV. Additionally clouds have been created between the MAs if desired as well as a selection of MAs and the choice of MA lengths for personal preference. Lastly it can also plot the lowest and highest values of OBV for x bars back so one can clearly see the movement of volume increasing or decreasing. For timing both price and volume, it is good to use the same MA lengths and type for both price and volume. This helps keep timing in sync and show a strong correlation between price and volume. Volume from Market Makers are the catalysts that drive the price up and down. Patience and timing are crucial for joining the volume created by the Market Makers.

If you are new to charting and technical indicators, pick up my Trade Archer - Moving Averages - v1 script as well. The defaults for both scripts have the same moving average type and lengths so timing is the same between Price and OBV moving averages.

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?
//Created By User Trade Archer (Kevin Johnson)
//Last Update 1/31/2015
//Added support for SMA, WMA, RMA, and VWMA.  Defaults to EMA
//Added plots of Highest and Lowest OBV x bars back
//Note: If you make some neat additions, let me know via PM.  Thanks & Enjoy
study(title="Trade Archer - On Balance Volume Moving Averages - v1", shorttitle="TA-OBVMAs-v1", overlay=false, precision=2)

//Collect input
source = input(3, type=integer, defval=3, minval=0, maxval=6, title="OBV Source: open=0 high=1 low=2 close=3 hl2=4 hlc3=5 ohlc4=6")
fast = input(9, minval=1, title="Fast MA")
medfast = input(19, minval=1, title="Medfast MA")
medslow = input(50, minval=1, title="Medslow MA")
slow = input(200, minval=1, title="Slow MA")
lo = input(10, title="lowest length")

usesma = input(false, title="SMA", defval=false, type=bool, defval=false)
useema = input(true, title="EMA (default)", defval=true, type=bool, defval=true)
usewma = input(false, title="WMA", defval=false, type=bool, defval=false)
userma = input(false, title="RMA", defval=false, type=bool, defval=false)
usevwma = input(false, title="VWMA", defval=false, type=bool, defval=false)

//Translate source
src = source == 0 ? open :
      source == 1 ? high :
      source == 2 ? low :
      source == 3 ? close :
      source == 4 ? hl2 :
      source == 5 ? hlc3 :
      source == 6 ? ohlc4 :
      close

//Get OBV
obv = cum(change(src) > 0 ? volume : change(src) < 0 ? -volume : 0*volume)

//Selects check MA type.  Defaults to EMA
fema = usesma ? sma( obv, fast) : useema ? ema( obv, fast) : usewma ? wma( obv, fast) : userma ? rma( obv, fast) :
       usevwma ? vwma( obv, fast) : ema( obv, fast)
mfema = usesma ? sma( obv, medfast) : useema ? ema( obv, medfast) : usewma ? wma( obv, medfast) : userma ? rma( obv, medfast) :
        usevwma ? vwma( obv, medfast) : ema( src, medfast)
msema = usesma ? sma( obv, medslow) : useema ? ema( obv, medslow) : usewma ? wma( obv, medslow) : userma ? rma( obv, medslow) :
        usevwma ? vwma( obv, medslow) : ema( obv, medslow)
sema = usesma ? sma( obv, slow) : useema ? ema( obv, slow) : usewma ? wma( obv, slow) : userma ? rma( obv, slow) :
       usevwma ? vwma( obv, slow) : ema( obv, slow)

//Plot Original OBV, Highest OBV and Lowest OBV x bars back
hp = plot( ceil(highest(obv,lo)), color=gray, linewidth=2, title="highest x bars")
lp = plot( floor(lowest(obv,lo)), color=gray, linewidth=2, title="lowest x bars")
pobv = plot(obv, color=black, linewidth=2, title="obv")

//Plot the MAs of OBV
pf = plot(fema, color=green, linewidth=1, title="fast avg")
pmf = plot(mfema, color=orange, linewidth=1, title="med fast avg")
pms = plot(msema, color=red, linewidth=2, title="med slow avg")
ps = plot(sema, color=maroon, linewidth=1, title="slow avg")


//fill between two emas
fill(pf, pmf, color=green, transp=45, title="short")
fill(pmf, pms, color=orange, transp=45, title="medium")
fill(pms, ps, color=red, transp=45, title="slow")