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
Nicolas Rien, il faut l'appliquer sur la charte. Soit le mettre sur le graphique du prix, à l'aide d...
signorini Merci pour votre réponse. Je l'applique sur la charte, j'utilise la petite clé pour effacer ...
signorini Je vous remercie, Nicolas. C'est fixé. Très bon week-end.
Abz  hi , you need to add the indicator from the "price" menu in chart
Francesco Thank you Abz!
phanz Hi Nicolas, this is an interesting strategy. For long position, I assume entry when prices ...
Pelle Nævestad Thanks Nicolas, this is a keeper!
Chicane23 Hi, when uploaded the WAE isnt showing histogram; only line. Is there a way to modify?
Nicolas Change the way the lines are displayed in the indicator settings window : histogram, lines, ...
Dimi.A Perfect for counter-trend scalping. I like this!
viktorthuns Hi Nicolas! Great work you've done with all your indicators. Just wondering about the code a...
Nicolas the value is not a boolean but an average of an addition of booleans. As stated in the descr...
xel @DerPat - I don't see any question regarding the indicator.  Anyway, I think I give enough l...
diegofe_2000 Xel, tu eres el creador de este indicador? Bueno te  cuento que es muy bueno para hacer est...
xel Buen día @diegofe_2000 -  Claro, mandalo y por aquí lo probamos en otros instrumentos y si g...
r.angel It seems that the formula needs a SQRT (that is Vyangzhang = SQRT(...))
RickTrader I think to have annualized view of this historical volatility you will need : Vyangzhang =...
Sofitech Bonjour. J'aimerais savoir s'il est possible de "truquer" un peu l'indicateur pour qu'il don...
Maz I actually like this very simple idea. It can also be useful for market micro-structure syst...
Nicolas Thanks Maz, I'll have a look tomorrow.

Top