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 judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        21 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X