Variable Moving Average (VMA)

Variable Moving Average (VMA)

A VMA is an EMA that is able to regulate its smoothing percentage based on market inconstancy automatically. Its sensitivity grows by providing more weight to the ongoing data as it generates a better signal indicator for short and long-term markets.

The majority of ways for measuring Moving Averages cannot compensate for sideways moving prices versus trending markets and often generate a lot of false signals. Longer-term moving averages are slow to react to reversals in trend when prices move up and down over a long period of time. A Variable Moving Average regulates its sensitivity and lets it function better in any market conditions by using automatic regulation of the smoothing constant.

The Variable Moving Average is also known as the VIDYA Indicator. But this version is a modified concept of the VIDYA.

The Variable Moving Average was developed by Tushar S. Chande and first presented in his March, 1992 article in Technical Analysis of Stocks & Commodities magazine, in which a standard deviation was used as the Volatility Index. In his October, 1995 article in the same magazine, Chande modified the VIDYA to use his own Chande Momentum Oscillator (CMO) as the Volatility Index, the VMA code below is the result of this modification.


Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials

  1. Matriciel • 164 days ago #

    Bonjour Nicolas,

    Je me suis amusé à doubler la VMA. Je ne sais pas si cela a un intéret…mais maintenant c’est fait ! 🙂

    //PRC_Variable Moving Average | indicator
    //Nicolas @
    //Sharing ProRealTime knowledge
    //converted and adapted from Pinescript version
    // --- parameters
    //l = 4
    if barindex>l then
    k = 1.0/l
    pdm = max((src - src[1]), 0)
    mdm = max((src[1] - src), 0)
    pdmS = ((1 - k)*(pdmS[1]) + k*pdm)
    mdmS = ((1 - k)*(mdmS[1]) + k*mdm)
    s = pdmS + mdmS
    pdi = pdmS/s
    mdi = mdmS/s
    pdiS = ((1 - k)*(pdiS[1]) + k*pdi)
    mdiS = ((1 - k)*(mdiS[1]) + k*mdi)
    d = abs(pdiS - mdiS)
    s1 = pdiS + mdiS
    iS = ((1 - k)*(iS[1]) + k*d/s1)
    hhv = highest[l](iS)
    llv = lowest[l](iS)
    d1 = hhv - llv
    vI = (iS - llv)/d1
    vmacourte = (1 - k*vI)*(vmacourte[1]) + k*vI*src
    // --- parameters
    //l2 = 9
    if barindex>l2 then
    k2 = 1.0/l2
    pdm2 = max((src2 - src2[1]), 0)
    mdm2 = max((src2[1] - src2), 0)
    pdmS2 = ((1 - k2)*(pdmS2[1]) + k2*pdm2)
    mdmS2 = ((1 - k2)*(mdmS2[1]) + k2*mdm2)
    s2 = pdmS2 + mdmS2
    pdi2 = pdmS2/s2
    mdi2 = mdmS2/s2
    pdiS2 = ((1 - k2)*(pdiS2[1]) + k2*pdi2)
    mdiS2 = ((1 - k2)*(mdiS2[1]) + k2*mdi2)
    d2 = abs(pdiS2 - mdiS2)
    s12 = pdiS2 + mdiS2
    iS2 = ((1 - k2)*(iS2[1]) + k2*d2/s12)
    hhv2 = highest[l2](iS2)
    llv2 = lowest[l2](iS2)
    d12 = hhv2 - llv2
    vI2 = (iS2 - llv2)/d12
    vmalongue = (1 - k2*vI2)*(vmalongue[1]) + k2*vI2*src2
    RETURN VMACOURTE coloured (100,100,215), VMALONGUE coloured (255,0,150)


  2. Matriciel • 164 days ago #

    Je n’arrive pas à joindre l’image qui montre la VMA Doublée…:(

    • Nicolas • 164 days ago #

      Merci pour l’indicateur double VMA ! En effet, ajouter des images serait un plus dans les commentaires, je dois m’en occuper prochainement.

  3. Ernesto1 • 162 days ago #

    L’ indicateur a changé de Matriciel, pas vu sur 10-3.
    vous  pouvez résoudre ce problème?

    • Nicolas • 162 days ago #

      Une solution rapide consisterait à placer 2 fois l’indicateur avec des valeurs de “l” différente sur votre graphique Ernesto1.

  4. supertiti • 160 days ago #

    Voici un code de VIDYA construit par Sohocool :

    if (STD[m](close)) <> 0 then
    k= STD[n](close) / (std[m](close))
    filt= a*k*close + (1-(a*k))*filt[1]
    cc = customclose
    return cc as " cc " , filt as "vidya"
    // variables :
    //  n =  9  alpha et standard deviation
    //  m = 30  standard deviation
    //  a  = alpha


    • Matriciel • 160 days ago #

      Merci Supertiti.

      Je trouve que ce code est difficile à règler et n’est pas d’une grande précision.

  5. Ernesto1 • 160 days ago #

    J’ai essayé avec deux différents I ,  a =  3 périodes et un 3 x 5 = 15 périodes.
    Ie comme si le TF est lissée de 3 minutes à 15 minutes, ceci est le résultat ..

  6. Wilko • 63 days ago #

    Nicolas, anytime I have an idea, I just search for it on ProRealCode and usually you have done an adaptation. Excellent work, thanks!

    I am aware I have promised to post something of my own, and would very much like to adapt the above to use R2 instead of CMO. However, this is spontaneously above my capabilities. Any chance you would be interested to have a go?


    Kind regards,


    • Nicolas • 62 days ago #

      Of course! please add a query in probuilder forum and we’ll work together on this indicator project.

Register or


avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Nicolas Hi Maz, it's always a pleasure to review your post, they are always perfectly well formatted...
Robert Great work! Could be useful :)
Tedvin Nice one, thanks a lot Maz :)
supertiti Il manque 2 slash devant len dans le code dur car la variable ne marche pas bonne journée
Nicolas Forum svp, avec des images pour bien expliquer merci :) 
finplus oui bien sûr j'ouvre le sujet immédiatement.  
denmar Hi Nicolas Any chance you could please modify the code slightly for me? I would like it if ...
Merls Hi Nicholas, Is it possible to add the Mansfield RS criteria in also? I have been trying to ...
Onythan Hello Nicolas, Thanks for this screener. I was wondering if I could add a criteria in order...
Nicolas 50 results is the limit, but you can get more with PRT-CFD premium : https://www.prorealcode...
Kris V Hi Gabri, Thanks for this interesting indicator, I am not a programmer and have a small pro...
gabri Kris, let me know which color you want to use. The lines to change are the 22,23,24.
Riccardo Benedetti Thanks a lot nicolas for this indicator. good job. I love the great work done simple. Thanks...
Riccardo Benedetti ciao nicolas mi piacerebbe provare a fare un backest di una strategia con questo indicatore ...
TheAccountant Bonjour et merci pour cet indicateur. j'essai de parametrer une alerte sur le changement de...
Sofitech Ce code n'est valable que sur la V10.3 ? sur le 10.2 il y a une erreur de syntaxe dans le fi...
Nicolas Oui en effet, c'est un indicateur "10.3" à cause uniquement de la mise en forme des courbes ...
piarou Objet : PRC_QEMA | indicator Bonjour, Bizarrement : • les deux paramètres sont en remarqu...
Nicolas En effet, c'est le cas si on copie/colle le code. Ces 2 variables sont inscrites en externes...
5 months ago
Holt EMA
Holt EMA
David Nicolas I've looked at it again and there's a problem.  As an example here's a simple cross...
Nicolas You'll need to preload bars to get the good calculations of you indicators. I did not test i...
David Nicolas I tried DEFPARAM Preloadbars = 5000 And still the same drawn output of entries/exit...
6 months ago
Nicolas Because of no data available at the start of calculations. Add this at line 15 : if barindex...
srajtri Hi Nicolas, thanks for your updates and am very new in trading would you guide me to back t...
Nicolas Please post any question on forums, thanks.
luigi Ciao Nicolas. Approfitto di questo spazio per chiederti se puoi aiutarmi. Avrei bisogno di u...
Nicolas Si prega di utilizzare i forum per chiedere richieste di codice per favore.
Wilko Hi Nicolas!, Thanks for providing code for the FRAMA! If I have understood correctly, one s... HELP, WHY DONT I NOT GOT THE INDICATOR IN CHART. JUST UNDER?????????????
Nicolas Use the wrench on the upper left side of your price chart to add correctly indicator on PRICE.
bluetime6 Hello Doctrading.   Can you ask you for something? Can you code a screener screen po...
gianlox I added a simple momentum indicator (MACD). I think much better results:   achat = 0v...
gianlox achat = 0 vente = 0 MACD12M = MACDline[12,26,9](close) MACD12S = ExponentialAverage[9](MA...
IGOSNELL Thanks but unfortunately can't read German. If you can show that your strategies can work on...
Nicolas Thank you for contribution. Please consider that advertising is tolerate as long as you cont...  Hi, I cant make it work. And if you doing so much money. Why do you have to sell it? It don...
AleX 0 improvments, I tried a lot of modified version but no one was working. I think that only w...
Fabio Anthony Terrenzio this strategy works only in a well defined trend
brosly Good afternoon I am trying to get the complete code of lex strategy made by adolfo since I s...