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

Price Values on Volume Charts

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

    Price Values on Volume Charts

    Hi,

    I am running a simple indicator on a 500V CL chart. The indicator has CalculateOnBarClose set to true.Here is the print out of some high and low values.

    ==========
    Time = 3/30/2012 12:50:54 PM
    High[1] = 103.59
    High[0] = 103.56
    Low[0] = 103.5
    Volume[0] = 500
    ==========
    Time = 3/30/2012 12:52:03 PM
    High[1] = 103.56
    High[0] = 103.53
    Low[0] = 103.46
    Volume[0] = 500
    ==========
    Time = 3/30/2012 12:52:03 PM
    High[1] = 103.6
    High[0] = 103.59
    Low[0] = 103.46
    Volume[0] = 2000
    ==========

    Why am I getting two sets of results for the 12:52:03 PM time, and why is the volume on the second set of results 2000 when my chart is clearly 500V? Also, the second set of 12:52:03 results seems spurious. Can anyone shed any light on this? Thank you.

    #2
    I have figured out the following. As part of testing this portion of code I also had the statement

    Add(PeriodType.Volume, 2000);

    in the Initialize. I was not using it in any way in the code but somehow the code used it. This is very odd behaviour.

    Comment


      #3
      Hello Zeos6,
      Thanks for your post and I am happy to assist you.

      The OnBarUpdate event will trigger for each and every bar series and thus you are getting such prints. In case of multi series indicators you can filter each series with the BarsInProgress property.

      If you do not want the additional series then please remove the code Add(PeriodType.Volume, 2000); from the initialize section of the code.

      To understand multi-series concepts please refer here






      Please let me know if I can assist you any further.
      JoydeepNinjaTrader Customer Service

      Comment


        #4
        Thank you for your reply but I am well aware of the BarsInProgress, etc. The point of my post was that although the 2000V series was added, it was not being used, and according to your documentation should have been accessed as Highs[1][0] etc. I was simply using High[0] which should have only accessed the series on the chart and not the secondary series. So, why was the secondary series being accessed at all?

        Comment


          #5
          Hello Zeos6,
          NinjaTrader is a event driven application and OnBarUpdate event will trigger for each and every bar series.

          If you have a multi-series indicator then OnBarUpdate will trigger for every bar series.

          High[0] would return the value of the high of the last/current bar of the bar series which is currently being updated. Thus if the primary bar is being updated then High[0] will return the high of the primary bar. If the secondary bar is being updated then High[0] will return the high of the secondary bar.

          High[x][0] is used when you want to access the high of another bar series.

          For example please try these 2 codes.

          Code:
          protected override void OnBarUpdate()
          {
            Print("Bars in Progress = " + BarsInProgress.ToString() + " Close = " + Close[0].ToString()); 
          }
          and
          Code:
          protected override void OnBarUpdate()
          {
            if (CurrentBars[0] < 0 && CurrentBars[1] <0) return;
          
            if (BarsInProgress == 0)   //primary bar
            {
               Print("Primary bar close = " + Close[0].ToString() + " Secondary  bar close = " + Closes[1][0].ToString()); 
            }
            else if (BarsInProgress == 1)
            {
               Print("Secondary bar close = " + Close[0].ToString() + " Primary bar close = " + Closes[0][0].ToString());
            }
          }
          Do not forget to add an additional series.

          Please let me know if I can assist you any further.
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            I get it. Thanks. So what you are basically saying is that if it is the secondary series that is being updated then the High[0] will return the current high of the series on the chart at that time of update. Did not realize that. Thanks for clarifying it for me.

            Comment


              #7
              Hello Seos6,
              Glad you could get the concept.
              Please let me know if I can assist you any further.
              JoydeepNinjaTrader Customer Service

              Comment


                #8
                I did but have one more question:

                When you add series using
                Add(PeriodType.Volume,
                2000);

                What period types are available and how would I add a day bar based on RTH?

                Comment


                  #9
                  Hello Zeos6,

                  You can add any PeriodType supported by Ninjatrader, including custom bar types to some extent. http://www.ninjatrader.com/support/h...barsperiod.htm

                  For some periodicity there may be special methods, like for kagi bars you have to use AddKagi method





                  The secondary series will use the session template of the primary bar series only.

                  Please let me know if I can assist you any further.
                  JoydeepNinjaTrader Customer Service

                  Comment


                    #10
                    I understand but wanted to confirm the add for a day bar. Is the period for a day bar 1? Also, are you telling me that if the primary series session template is 24/7 I cannot add a day bar based on RTH? If this is so, how can I alter the session template for the added series progrmatically?

                    Comment


                      #11
                      Hello Zeos6,
                      Yes, use 1 for daily bars.

                      A secondary series will use the session template from the primary series only. Unfortunately currently there is no workaround for it.

                      Please let me know of I can assist you any further.
                      JoydeepNinjaTrader Customer Service

                      Comment


                        #12
                        Thanks. I need to be able to change the session template for the added series programatically.

                        Comment


                          #13
                          Hello Zeos6,
                          I will send your feature request to development for future consideration.

                          Please let me know if I can assist you any further.
                          JoydeepNinjaTrader Customer Service

                          Comment


                            #14
                            Hello Zeos6,
                            Development has assigned tracker id #957 for your feature request.

                            Please let me know if I can assist you any further.
                            JoydeepNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by bortz, 11-06-2023, 08:04 AM
                            47 responses
                            1,602 views
                            0 likes
                            Last Post aligator  
                            Started by jaybedreamin, Today, 05:56 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post jaybedreamin  
                            Started by DJ888, 04-16-2024, 06:09 PM
                            6 responses
                            18 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Started by Jon17, Today, 04:33 PM
                            0 responses
                            4 views
                            0 likes
                            Last Post Jon17
                            by Jon17
                             
                            Started by Javierw.ok, Today, 04:12 PM
                            0 responses
                            12 views
                            0 likes
                            Last Post Javierw.ok  
                            Working...
                            X