Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical Volatility

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Historical Volatility

    Hello,

    I have not succeeded in finding an indicator or calculation method for historical volatility in NT 7. I am surprised as HV is standard in technical software today.

    Is there an indicator or at least how can I use ln (natural log) to create an indicator myself?

    Thanks a lot and regards

    #2
    Math.Log(x) is ln(x). Math.Log(x, y) is log base y of x.

    You might want to also read this NT7 thread: https://forum.ninjatrader.com/forum/...lity-indicator
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello Bernhard_mu,

      Thanks for your post.

      The information QuantKey_Bruce provided could be used to create a NinjaScript indicator that calculates this value.

      Please see the forum thread that QuantKey_Bruce shared in their post for further information about calculating Historical Volatility in a custom NinjaScript.

      Let us know if we may assist further.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Hello,

        thanks for your quick reply!

        I tried to code a part of the historical volatility​ in an indicator but NT7 refused to plot me a value (see below). The problem must be in line 55. If I replace the variable "value" with let's say 90 "value = Math.Sqrt(90)" then I get a plot of 30. But the calculation of a variable does not work. How can I solve this?

        Click image for larger version

Name:	image.png
Views:	237
Size:	53.5 KB
ID:	1250545

        Comment


          #5
          You say it doesn't work. Does it not compile? Or does it plot the wrong value? Does it throw an exception in the Log tab of Control Center? Also, what is Tage? Is that an input parameter and if so, what value does it have?
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #6
            Hello Bruce,

            the Log tab says: Value outside of valid range. I wanted to take the square root of a negative value. This was the problem.

            Thanks a lot for your help and hint!

            Regards
            Bernhard

            Comment


              #7
              Okay. You cannot take the square root of a negative value using the Math.Sqrt function. You could replace line 55 with: value = Math.Sqrt(Math.Max(0, value)); There is such a thing in math as the square root of a negative number, but the answer would be a complex number that is some multiple of i, where i^2 = -1. However, Math.Sqrt only handles real numbers.
              Last edited by QuantKey_Bruce; 05-08-2023, 03:04 PM.
              Bruce DeVault
              QuantKey Trading Vendor Services
              NinjaTrader Ecosystem Vendor - QuantKey

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              646 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              367 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              107 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              569 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              573 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X