Loop to calculate historical volatility

Forums ProRealTime English forum ProBuilder support Loop to calculate historical volatility

Viewing 8 posts - 1 through 8 (of 8 total)
  • #121195

    Hello,

    I’m writing a script to measure a long chunk of volatility to find out if the current volatility is high or low.

    With one twist: At “1”, the indicator should be showing that we are at 100% normal historical volatility.

    I have managed to calculate historical volatility, but I can’t make the indicator display the data in the form of “1” = 100% of normal historical volatility.

    Here’s my ProRealTime code:

    Also, not sure if it helps, but I did manage to make it work properly in “PineScript”.

    Here is the working snippet in PineScript:

    I would appreciate your help A LOT to make the ProRealTime code version work.

    Thank you.

    #121199

    Line 1 in Pinescript code reads ATR (AverageTrueRange in PRT), while you wrote TR which is True Range.

    Can this be the source of your problem?

    #121200

    Already tried that, and it didn’t fix the issue, unfortunately.

    My guess is that the issue has something to do with the “By” element in the loop, which is present in the PineScript version, but not in my PRT code.

    I could not find any “By” equivalent for PRT…

    #121201

    Did you know that ProBuilder has an historical volatility instruction? It might help!

    #121203

    Yeah, I’ve tried it. But I couldn’t figure out how to use it for readings in the form that I need them.

    I need an indicator that shows where volatility currently is in comparison to the historical average.

    e.g. if the indicator gives a “0.5” reading, it should mean that volatility is currently 50% below historical average. If the indicator gives a “1.0” reading, it should mean that volatility is currently at the exact historical average. And so on…

    Do you know how I could do this?

    #121206

    My guess – not tested.

     

    2 users thanked author for this post.
    #121207

    You have to normalize the value in order to make a fixed scale.

    #121226

    Thanks Vonasi, that worked!

Viewing 8 posts - 1 through 8 (of 8 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login