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

Adding script generated values

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

    Adding script generated values

    Hello

    I am developing an indicator and this indicator returns values as the chart progresses. I would like to calculate a running total of these values for later use.

    The basic question is, would I use an array for such a task? If so, can you point me to the most clear explanation of how to accomplish this with an array?

    Here would be an example

    Date; Value; Running Total (RT)
    May 1; 5; 5;
    May 2; 3; 8;
    May 3; 9; 17;
    May 4; 7; 24;
    May 5; 10; 34;
    (forgive the poor table, I can't figure out a way to create one here)

    I would like the RT to be what is automatically calculated (and ultimately an oscillator type line created from that RT).

    Thank you for your help

    #2
    jg123, just to keep a running total you would not need an array type structure, consider we wanted to sum every 10th Close together then we could do -

    if (CurrentBar % 10 == 0)
    runningTotal += Close[0];

    The variable would just continue to add and thus keeping a running total.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thank you Bertrand for this answer.

      I haven't been able to really get this to work - so here is a bit more information about what i am trying to do and what I have done so far.

      I have a custom indicator that calculates the distance of swings based on Gann Swings. You can see the results of it on the Urban Outfitters chart that is attached.

      My goal is to keep a running total of each "Upswing" value. So, in the image attached, it would have something like:

      0 + 4.09 = 4.09
      4.09 + 2.93 = 7.02
      7.02 + 2.6 = 9.62

      etc.

      So far, for the code, I have not been able to figure out how to calculate this. I have referenced the indicator in the using declarations section.

      Can you point me in the right direction now of how to add those swing values together?

      Thank you very much for your help
      Attached Files
      Last edited by jg123; 09-22-2014, 05:12 AM.

      Comment


        #4
        jg123, thanks that's what I understood - first thing you would need to check into is if the value you would need to cumulate is exposed in a custom series / variable for access from the study you're working with to identify those.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Sorry, I just noticed that I called you Cal. I was reading another post from him, and his name was in my head. I changed it in my last post. Sorry about that.

          Okay, sounds good. I would assume that it is simply because I know other people on BMT are using this indicator and are referencing it with other indicators. But, just for knowledge sake and to confirm, how would I check into that?

          Comment


            #6
            No worries. Either this would be a plotted value (those are exposed per se for script access) or you would have an internal series that is made available via the code, you would need to review the code to find out or talk to the community members at BMT already accessing those value which property it would be.

            Generally this technique would be used to expose non plotted values for script access -

            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by AveryFlynn, Today, 04:57 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by Max238, Today, 01:28 AM
            4 responses
            37 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by r68cervera, Today, 05:29 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by geddyisodin, Today, 05:20 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by timko, Today, 06:45 AM
            2 responses
            14 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Working...
            X