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

Trade size of tick

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

    Trade size of tick

    Hi,

    I'm trying to figure out the right way to log trade size per tick. I am running with calculate on bar close set to false, so onbarupdate is called every tick.

    Can you confirm, does Volume[0] hold the volume for the tick, or the whole bar in progress? If for the whole bar, I need to record this value then subtract from current to calculate difference and thus tick volume/trade size?

    Thanks.

    #2
    Hello pjsmith,

    Thank you for your inquiry.

    Volume[0] would hold the volume of the entire bar in progress. You can demonstrate this by adding a VOL indicator to the chart you are running the strategy on, with Calculate on Bar Close set to false, and compare the values between the two.

    Both the strategy and the indicator will show the same values.

    If you would like to calculate the volume for each tick of data that comes in, you could add a secondary Bars object and only run your code when that particular Bars object calls OnBarUpdate().

    Example:
    Code:
    protected override void Initialize()
    {
         Add(PeriodType.Tick, 1);
    }
    
    protected override void OnBarUpdate()
    {
         if (BarsInProgress == 1) // if the second Bars object has called OnBarUpdate()
              Print(Volumes[1][0]); // print the volume of the tick series
    }
    The NinjaTrader help guide provides further information about this subject in the Multi-Time Frame & Instruments section: http://ninjatrader.com/support/helpG...nstruments.htm

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      Thank you. For clarity, with CalculateOnBarClose set to false, is not onbarupdate called every tick, regardless of the primary instrument data period?

      Comment


        #4
        Hello pjsmith,

        Yes, this is correct. With CalculateOnBarClose set to false, OnBarUpdate() will be called on every tick of data that comes in rather than on bar close.

        However, calling Volume[0] on a one minute Data Series, for example, will be returning the volume of the actual one minute bar itself, not the tick that comes in.

        To further demonstrate this, try printing Time[0] with CalculateOnBarClose set to false on a one minute bar. You will notice that the time will be the same until the bar closes and the next bar starts forming. The print is returning the minute bar time and not the time of the ticks coming in.
        Zachary G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DanielTynera, Today, 01:14 AM
        0 responses
        2 views
        0 likes
        Last Post DanielTynera  
        Started by yertle, 04-18-2024, 08:38 AM
        9 responses
        40 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by techgetgame, Yesterday, 11:42 PM
        0 responses
        12 views
        0 likes
        Last Post techgetgame  
        Started by sephichapdson, Yesterday, 11:36 PM
        0 responses
        2 views
        0 likes
        Last Post sephichapdson  
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,615 views
        0 likes
        Last Post aligator  
        Working...
        X