Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Open-Close of a period?

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

    Open-Close of a period?

    Hi community,

    how do i get my hands on the SUM of the OPEN-CLOSE of a given period?

    thanks in advance.

    #2
    Hi Puravida,

    Thanks for posting.

    You can use the SUM() feature with NinjaScript to calculate the Open and Close of a time frame.
    A sample of this code looks as such
    Code:
    // Prints the current value of a 20 period SUM using Close price type
    double value = SUM(Close, 20)[0];
    Print("The current SUM value is " + value.ToString());
    If you are looking to get the Open minus Close price, you can look into using the data series. Below is a link to a reference sample of how to use the data series.
    http://www.ninjatrader.com/support/f...ead.php?t=7299


    The link below will take you to the online help guide on using the SUM () in your code.
    http://www.ninjatrader.com/support/h...mation_sum.htm

    Please let me know if I can be of further assistance
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks, i think i found my problem.

      http://www.ninjatrader.com/support/h...ries_class.htm

      If you scroll down to the bottom, you can read the following statement which didn't worked for me:

      Code:
      protected override void OnBarUpdate()
      {
          // Calculate the range of the current bar and set the value
          myDataSeries.Set(High - Low);
      This one gives me a compile error... so i "fixed" it to:

      Code:
      protected override void OnBarUpdate()
      {
          // Calculate the range of the current bar and set the value
          myDataSeries.Set(High[0] - Low[0]);
      Am i missing something or is it really a typo in the documentation?

      Comment


        #4
        Hi Puravida,

        Thank you for pointing that out. I have sent that in to development and they are looking into it.

        Please let me know if I can be of further assistance.
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        576 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X