Logarithm Garman-Klass Volatility Estimator

Logarithm Garman-Klass Volatility Estimator

 

WHAT IS THIS?

This is my personal port of the Logarithmic Garman-Klass as openly found at  iVolatility.com.

This estimator tends to be as fast as the RiskMetrics EWMA but without the noisy overshooting and will not lag as other estimators based on pure arithmetic Standard Deviation like Close-To-Close HV, Original Garman-Klass, Parkinson’s, Rogers-Satchell’s, Yang-Zhang, etc.

Cheers, and any contributions will be welcome.

THE CODE:

DISCLAIMER:   The Following indicator/code IS NOT intended to be a formal investment advice or recommendation by the author, nor should be construed as such. Users will be fully responsible by their use regarding their own trading vehicles/assets. 

The embedded code and ideas within this work are FREELY AND PUBLICLY available on the Web for NON LUCRATIVE ACTIVITIES and must remain as is by Creative-Commons and in regard of ProRealCode regulations.   Any use, copy or re-use of this code should mention it’s origin as it’s authorship.

XeL 2017

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?

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

  1. xel • 09/12/2017 #

    Hi! I found myself that the indicator posted here contain an error, I want to edit or fix it as it is not drawing well. [ CC @nicolas ]

    The correct algorithm in code should be this:

    Lookback = 30
    Compound = 252
    ///////////////////
    // LOGARITHM GARMAN-KLASS VOLATILITY ESTIMATOR by @Xel_arjona
    // Ported to ProRealCode as Formulae openly described in http://www.ivolatility.com/help/7.html
    lnCC = log(close/close[1])
    lnCO = log(close/open)
    lnOC = log(open/close[1])
    lnHL = log(high/low)
    // Lambda definition:
    lambda = Lookback/(Lookback+3)
    //Initialization with Close-To-Close Historical Volatility
    varCC = summation[Lookback](square(lnCC)) / Lookback
    //Logarithmic Garman-Klass Realized/Historical Estimate as in iVolatility.com
    if barindex < Lookback+4 then
    varLGK = varCC
    else
    GK = square(lnOC) + 0.5*square(lnHL) - 0.386*square(lnCO)
    LGK = log(varCC)
    LGK = ((1-lambda)*log(GK[1])) + (lambda*log(LGK[1]))
    varLGK = exp( LGK )
    endif
    LGKest = sqrt(varLGK)*sqrt(Compound) * 100
    // PLOT DIRECTIVE
    RETURN LGKest as "LGK"

    The correction is on the Autoregresive definition for LGK, which should be refered to last value “LGK[1]” instead of current. Even this patch is applyed; the code itself do not print correct values (giving only zeros), but this is a possible limitation on PRT or a missundestood of mine for the internals of ProRealCode. This same kind of algorithm do some errors for other indicators of mine also. https://www.prorealcode.com/topic/plot-issue-with-custom-exponential-indicator/

    Cheers and sorry for the inconvenience.

avatar
Register or

Likes

avatar avatar avatar avatar
Related users ' posts
Bard Problems with Safari latest s/ware and this site and links and adding code. Let me add the...
grimweasel47 Ok thanks Nicolas - could this be adapted to take into account MFI and then have price, volu...
Nicolas I don't understand what you mean exactly, would be better to open a topic about this idea wi...
jissey Bonjour Bolsatrilera,j'essaie de vous contacter pour le cm rsi ;je le trouve interessant, m...
jissey J'essaie de vous contacter pour l'indicateur"cm rsi"....
joobeng Sorry, I solved the problem. I have add the CBL indicator using the spanner icon on the pric...
Nicolas Adjust the price settings for the Y Axis to use the price only.
XXXXVII Hello Your indicator is interesting. However, I can't see the orange line. Do you have ...
jebus89 Big thanks for sharing this :) Seems to work as expected, good stuff.
flodefacebook Merci Nicolas pour cet indicateur. Très utile dans une technique de retournement.
HeikinAshi thank you for this very interesting indicator Nicolas! did you define a tradable setup fo...
christophe11560 salut gabri, Je n'ai pas de commentaire sur "s*s", c'est ton choix personnel. Je me posais...
gabri Hi, the SQRT(254) it is used to annualize the value. In terms of the "s*s" I just used the s...
christophe11560 Merci pour ton retour
guillermus69 is this " a= log(close/close[1])" better than a = ((close/close[1]) -1) *100 . I ...
gildaslm Hi gabri, thanks very much for your work, it helps me a lot. Have you ever tried to make the...
gandolfi thanks for your screener. Do you have the code for original Sharp ratio in order to compare ...
Abz Thanks gabri
Mattzi In your opinion is less than 20 stocks a bad idea? Thank you.
gabri No, you can pick as many or as little as you want. The portfolio composition depends on many...
Lotech123 Thanks for this indicator. Working on a 3 M timeframe with the DJI, it can produce some inte...
JSTAR PRODUCTIONS Hi there, I downloaded the Indicator but the indicator does not show up on my charts. Am...
JSTAR PRODUCTIONS Hi, Worked it out. Thanks
poonsl2828 Hi! Francesco I have test it on GBP/USD but it only have a trade on 9 Jun which i backtes...
ullle73 why not use 1h chart? has 95% hitrate
ullle73 i see most of positions are only 1 pip before exit?
Francesco78 Hi Pepmartorell, please let's continue the discussion on the forum thread so that we can sha...
Francesco78 Hi Pepmartorell, please let's continue the discussion on the forum thread so that we can sha...
Jusmih1 Hi there, i am looking at your Strategy however when you put in automatic trading mode its ...
bruces Hi. Thank you that is what I am looking for. As well as the chart, I want to also add to a...
Jodal Bonjour Nicolas, Merci pour cet indicateur! Est-ce possible de configurer une alerte pou...
Nicolas Merci pour le post dans le forum en respectant les règles de publication énoncées dans le ca...
Dron De lo mejorcito
fabio407 Thanks, Nicolas. Very useful. Would you tell me where to find what result conveys the functi...
Nicolas This is not an instruction of the programming language but a variable from this indicator (l...
fabio407 OK. I didn't notice it. Many thanks, Nicolas!
Wilko And not only readable.... makes it much easier to iterate different entry/exit-conditions, d...
IGOSNELL Hi Interesting strategy, when I used $ M-R Dif EURUSD M15 Long if does not enter any positi...
ilvillans HI, I modified the system, from good results but from this error: Replace the variables wit...
Nicolas Restart your platform in order to be sure to use the last version, there was a version rollb...
bertrandpinoy bonjour voud pouvez m envoyer le code modifier par vous?
Nicolas Désolé , je ne comprends pas votre question.

Top