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 funk10101, Yesterday, 09:43 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        5 responses
        551 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by rtwave, 04-12-2024, 09:30 AM
        5 responses
        37 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by funk10101, Today, 12:02 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by GLFX005, Today, 03:23 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X