Variable Moving Average Bands [LazyBear]

צפיות ‎10036‎
VMA Bands are ATR bands with VMA as its centre. For a description of options, refer to my VMA post:
I have moved VMA calculation in to a separate function. Feel free to use calc_vma() in your scripts. For more MA calculation function ( KAMA , VIDYA and others), refer to my complete list of indicators below.

Wish you all a very prosperous New year. Hope these indicators make you all more money this year too :)

List of my other indicators:
- GDoc:
- Chart:
סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר סקריפט זה פרסם אותו עם קוד פתוח, כך שסוחרים יוכלו להבין ולאמת זאת. הידד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום הנו בכפוף ל כללי הבית . אתה יכול להגדירו כמועדף ולהשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?
// @author LazyBear 
// List of all my indicators: 
study(title="Variable Moving Average Bands [LazyBear]", shorttitle="VMABANDS_LB", overlay=true)
l=input(6, title="VMA Length") 
bm=input(1.5, title="Bands Multipler")
std=input(false, title="Show Trend Direction")
bc=input(false, title="Color bars based on Trend")
calc_vma(src, l) => 
    k = 1.0/l
    pdm = max((src - src[1]), 0)
    mdm = max((src[1] - src), 0)
    pdmS = ((1 - k)*nz(pdmS[1]) + k*pdm)
    mdmS = ((1 - k)*nz(mdmS[1]) + k*mdm)
    s = pdmS + mdmS
    pdi = pdmS/s
    mdi = mdmS/s
    pdiS = ((1 - k)*nz(pdiS[1]) + k*pdi)
    mdiS = ((1 - k)*nz(mdiS[1]) + k*mdi)
    d = abs(pdiS - mdiS)
    s1 = pdiS + mdiS
    iS = ((1 - k)*nz(iS[1]) + k*d/s1)
    hhv = highest(iS, l) 
    llv = lowest(iS, l) 
    d1 = hhv - llv
    vI = (iS - llv)/d1
    vma=(1 - k*vI)*nz(vma[1]) + k*vI*src

vma=calc_vma(src, l)
vmaC=(vma > vma[1]) ? green : (vma<vma[1]) ? red : (vma==vma[1]) ? blue : black 
plot(vma, color=std?vmaC:black, linewidth=3, title="VMA")
ubx=plot(uband, color=gray, linewidth=2, title="UpperBand")
lbx=plot(lband, color=gray, linewidth=2, title="LowerBand")
fill(ubx,lbx, color=black, transp=95)
List of my free indicators:
List of my indicators at Appstore:


Very nice, indebted to yours, ucsgears and ChrisMoody's scripts.
Great work, as usual.
Have you used these, or just coding them for fun?
+4 השב
LazyBear IvanLabrie
I do use them occasionally to get a different feel, but usually stick to only a few (1 momentum & 1 volume).

Each new indicator teaches me something new about price though, so mostly I code to learn :)
+3 השב
IvanLabrie LazyBear
Very nice, I've been trying a similar approach heh, but my coding is subpar. :p
Thanks for sharing this, LazyBear. I wanted to point out a calculation bug fix where at the beginning of the chart the VMA band will dip down to zero and start from there. You can stop that from happening if you change line 30. There may be a better choice than src, but it seems better place to start than 0. Hope this helps.

vma=(1 - k*vI)*nz(vma) + k*vI*src

vma=(1 - k*vI)*nz(vma, src) + k*vI*src
Hello sir
Can you make our owe indicator ? Pls let me know .
Hello, I know this is from a while ago so you might not see this, but what is the length of the ATR for these? the standard 14? I absolutely love your indicators and I'm digging deep!
Thanks! Very good tool. Great work.
LazyBear sudhir.mehta
O-o wow.....
Mad Skills