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

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 algospoke, Today, 06:40 PM
        0 responses
        2 views
        0 likes
        Last Post algospoke  
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        6 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        6 views
        0 likes
        Last Post quantismo  
        Started by AttiM, 02-14-2024, 05:20 PM
        8 responses
        167 views
        0 likes
        Last Post jeronymite  
        Started by cre8able, Today, 04:22 PM
        0 responses
        8 views
        0 likes
        Last Post cre8able  
        Working...
        X