LazyBear

Variable Moving Average Bands [LazyBear]

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: docs.google.com...ByMEvm5MLo/edit?usp=sharin...
- Chart:

List of my free indicators: bit.ly/1LQaPK8
List of my indicators at Appstore: blog.tradingview.com/?p=970
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?
//
// @author LazyBear 
// List of all my indicators: 
// https://docs.google.com/document/d/15AGCufJZ8CIUvwFJ9W-IKns88gkWOKBCvByMEvm5MLo/edit?usp=sharing
// 
study(title="Variable Moving Average Bands [LazyBear]", shorttitle="VMABANDS_LB", overlay=true)
src=close
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

vma=calc_vma(src, l)
o=bm*atr(l) 
uband=vma+o
lband=vma-o
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)
barcolor(bc?vmaC:na)