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 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?
    BertrandNinjaTrader Customer Service

    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?
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        238 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        4 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Started by pechtri, 06-22-2023, 02:31 AM
        10 responses
        125 views
        0 likes
        Last Post Leeroy_Jenkins  
        Working...
        X