Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Volume

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

    Adding Volume

    I am having problems adding two volumes together. The below code works as long as I do not set the "barsago" higher than 5. How do I add twovolumes together and display them to check. I would like to add current bar "Volume [0]" and add a data bar's volume 1000 bars ago "Volume [1000]"

    Every instance I change the "Volume [3]" to > Volume [5] nothing displays.

    double Myvolume = Volume [0] + Volume [3];
    DrawTextFixed("tag1", Myvolume.ToString(), TextPosition.TopLeft);
    Last edited by loujen213; 02-05-2012, 09:42 PM.

    #2
    loujen213, do you see any error message in the log tab of NT's Control Center when the indicator stops to work for you? What CurrentBars check do you run at the OnBarUpdate() start? Is this perhaps not high enough for your 5 bar lookback?

    Comment


      #3
      No error message in the control center. CurrentBar check? Is there a different way to add two volume bars together Volume [1] and Volume [120] and then display it at the top to check? If so can you show me a different way?

      I do not think the look back is the problem. I have a 1 minute chart with 24hr continuous data.


      Thank you for your help. I am very new to ninjascript so i apologize for not understanding

      Comment


        #4
        This is not to be confused with the lookback for the chart, let me explain.

        As your chart and therefore OnBarUpdate() calls for the script begin you are on the first bar of the series, so think of CurrentBar == 0.

        At this point in time there is no prior bar available, so any call to an index other then 0 will fail unfortunately.

        To prevent this, ensure OnBarUpdate() is called from bar 5 for example onwards - if you add

        if (CurrentBar < 5) return;

        at the top of your OnBarUpdate() and press F5 to compile those changes in and then rerun the script, would it work for you?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        637 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 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
        571 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X