Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Volatility and Standard Deviation

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

    Volatility and Standard Deviation

    I am attempting to program an historical volatility measure but am unable to resolve problems of data type and series. Affected coding is as follows.

    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values.

    double mLog1 = Close [0] / Close [1]; // works fine
    double mLog2 = Math.Log(mLog1); // works fine
    double mSqrt = Math.Sqrt(365)*100; // works fine

    double test = StdDev(mLog2,100) [0] * mSqrt;
    // mLog2 type and series are the problems I cannot fix

    Plot0.Set(test);

    }

    I appreciate your help.

    Andrew

    #2
    Hi Andrew,

    mLog2 needs to be a DataSeries, not a double.

    VT

    edit to expand:

    in Variable region add:
    private DataSeries mLog2;

    in Initialize() add:
    mLog2 = new DataSeries(this);

    in OnBarUpdate() define mLog2 using the Set method:
    mLog2.Set(Math.Log(mLog1));
    Last edited by VTtrader; 11-19-2011, 01:53 PM.

    Comment


      #3
      Volatility and Standard Deviation

      Thanks for your quick reply.

      I recognize that mLog2 needs to be a DataSeries, not a double. But I'm just new enough to NinjaTrader scripting to not know how to correct the problem. Could you explain in greater detail or refer me to an appropriate reference?

      Thank you,

      Andrew

      Comment


        #4
        Did you see my edit? If you need more help let me know.

        VT

        Comment


          #5
          Whoops. I see that you've already explained how to handle the problem.

          Thanks again,

          Andrew

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by zstheorist, Today, 07:52 PM
          0 responses
          7 views
          0 likes
          Last Post zstheorist  
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          150 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Started by mattbsea, Today, 05:44 PM
          0 responses
          6 views
          0 likes
          Last Post mattbsea  
          Started by RideMe, 04-07-2024, 04:54 PM
          6 responses
          33 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Started by tkaboris, Today, 05:13 PM
          0 responses
          6 views
          0 likes
          Last Post tkaboris  
          Working...
          X