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

clarify Add() in BarsType

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

    clarify Add() in BarsType

    howdy,

    looking for some clarification from engineering regarding @BarsType.cs

    inside of the Add() method, which is called on each tick, there are two methods used to populate bars: AddBar() and UpdateBar().

    both take a volume parameter.

    two questions:
    - does the volume passed to AddBar() set/update bar.Volume? or does it add the volume passed to the current bar.Volume?
    - same question for UpdateBar()

    i don't think it matters whether it sets or appends for the AddBar, since that should only be called on a new bar, meaning bar.Volume would be 0.

    but the specific implementation would make a difference for UpdateBar since bar.Volume would presumably be > 0 when one invokes UpdateBar.

    thanks in advance for clarifying.

    cheers,
    -e

    #2
    Hello e-man,

    Custom Bar types are not something that we can support, but I will leave this forum open for responses from the community.

    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      i can venture a guess to my own question, based on TickBarsType:

      Code:
      if (bars.Count > 0 && !bars.IsNewSession(time, isRealtime) && bars.Period.Value > 1 && bars.TickCount < bars.Period.Value)
                          UpdateBar(bars, open, high, low, close, time, volume, isRealtime);    
                      else
                          AddBar(bars, open, high, low, close, time, volume, isRealtime);
      it would appear that when UpdateBar fires, bar.Volume becomes bar.Volume + volume

      please correct me if i'm wrong.

      next question (to make sure i understand):
      if bar.Volume is passed into UpdateBar as the volume parameter, would that essentially double the bar.Volume?

      cheers,
      -e

      Comment


        #4
        Hello e-man,

        Bar Type methods are going to be undocumented and therefore something that we cannot support. You can always try out the code and see the results to be able to find out how the code is running. With that said, there are a few Custom Bar Type available to download from the following section that you can try to use as reference:

        http://www.ninjatrader.com/support/f...ks.php?catid=6

        Let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_JC View Post
          Hello e-man,

          Custom Bar types are not something that we can support, but I will leave this forum open for responses from the community.

          Let us know if we can be of further assistance.
          hmmm, ok ... i'll try a different approach.

          in KagiBarsType (released with the default NT7 @BarsType.cs file), there is a private variable called volumeCount.

          on lines 425-428 we have this code:
          Code:
                      if (endOfBar)
                          CalculateKagiBar(bars, o, h, l, c, prevTime, volume, isRealtime);
                      else
                          volumeCount += volume;
          so when completing a Kagi bar, the current volume is passed to a private method CalculateKagiBar.

          otherwise, volume gets added to volumeCount

          inside CalculateKagiBar, we have invocation of both AddBar() and UpdateBar(). both pass in volumeCount. and then volumeCount is re-initialized to be the current-print's volume.

          so that would suggest that volume is being completely overwritten by UpdateBar()

          the only way i can make sense of that is if the volume parameter passed into Add() (not AddBar(), but the main method for BarsType) for the current-print is cumulative volume for the current bar.

          i've probably over-complicated the issue, but a real answer from engineering would be very helpful. :-)

          cheers,
          -e

          Comment


            #6
            e-man,

            Here is a some help...

            AddBar(,,,vol,…) – would add a new bar with Volume of “vol”
            UpdateBar(,,,vol,…) – updates the current bar by adding “vol” to the current Volume
            RayNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Ray View Post
              e-man,

              Here is a some help...

              AddBar(,,,vol,…) – would add a new bar with Volume of “vol”
              UpdateBar(,,,vol,…) – updates the current bar by adding “vol” to the current Volume
              thanks, Ray!

              that was my first thought, but the Kagi implementation confused me. i must have missed something when i was reviewing that code earlier.

              my previous thought was that volCount was holding the sum-total volume for the current bar, but that cannot be the case; otherwise, volume would be seriously overstated on Kagi charts.

              again, thanks for the clarification. much obliged.

              cheers,
              -e

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              26 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, Yesterday, 09:53 PM
              2 responses
              49 views
              0 likes
              Last Post wzgy0920  
              Started by Kensonprib, 04-28-2021, 10:11 AM
              5 responses
              191 views
              0 likes
              Last Post Hasadafa  
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,230 views
              0 likes
              Last Post xiinteractive  
              Working...
              X