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

Ninjascript "Bars.TickCount"

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

    Ninjascript "Bars.TickCount"

    Hi there,

    It would appear Bars.TickCount doesn't do what it is supposed to do ...

    ... from the NinjaTrader 7 Help:

    TickCount
    Definition
    The total number of ticks of the current bar.
    Property Value
    A int value that represents the total number of ticks of the current bar.

    Syntax
    Bars.TickCount

    I have run the following strategy on a variety of timeframes ... it seems that Bars.TickCount currently returns BarsPeriod.Value (ie., for a 5min chart, it returns 5, for a 250-volume chart, it returns 250, etc.).

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    ///
    /// </summary>
    [Description("")]
    public class DemoTickCountBug : Strategy
    {
    #region Variables
    // Wizard generated variables
    // User defined variables (add any user defined variables below)
    int _MinTickCount;
    int _MaxTickCount;
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    _MinTickCount = 0;
    _MaxTickCount = 0;
    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (_MinTickCount == 0)
    _MinTickCount = Bars.TickCount;

    _MinTickCount = Math.Min( _MinTickCount, Bars.TickCount );
    _MaxTickCount = Math.Max( _MaxTickCount, Bars.TickCount );
    Print("Bar# " + CurrentBar + " TickCount : " + Bars.TickCount + " - MinTickCount : " + _MinTickCount + " - MaxTickCount : " + _MaxTickCount );
    }

    #region Properties
    #endregion
    }
    }
    Attached Files

    #2
    Hello,

    This is a real-time property that will return the number of ticks on the most current bar on the chart.

    For example using with Calculate OnBarClose set to false:

    Code:
    Print("The tick count of the current bar is " + Bars.TickCount.ToString());
    You should see output counting the number of ticks in the most current bar which should increase as you receive more ticks.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Do you mean it only works in real-time ?

      Is there a way to get this value for any bar in the history (similar to Volumes[n] ) ?

      Comment


        #4
        Hello,

        You would need to Add() a 1 tick data series in order to count the number of ticks in each bar:



        Adding the ability to count the number of ticks in a historical bar is on our development team's list of future considerations tracked using ID #1280
        MatthewNinjaTrader Product Management

        Comment


          #5
          Originally posted by NinjaTrader_Matthew View Post
          Hello,

          You would need to Add() a 1 tick data series in order to count the number of ticks in each bar:



          Adding the ability to count the number of ticks in a historical bar is on our development team's list of future considerations tracked using ID #1280
          Will this be available in NT 8.0 when it is released?

          Can you speak to the performance ramifications of adding the 1 tick series when backing testing say 6 months of Volume Bars charts ... say on ES? Will this slow backtesting down significantly?

          Comment


            #6
            We do not have confirmation as to what features will be for sure available in the next major version, but it is something we'd like to see. We'll have more information closer to the release date.

            As there are more data points, it would be more resource intensive and would take longer to process.
            MatthewNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by SentientDavid, Today, 01:34 AM
            0 responses
            2 views
            0 likes
            Last Post SentientDavid  
            Started by MrForgetful, Today, 01:28 AM
            0 responses
            2 views
            0 likes
            Last Post MrForgetful  
            Started by falcondroneus, Today, 01:15 AM
            0 responses
            2 views
            0 likes
            Last Post falcondroneus  
            Started by Vikuno1, 11-28-2023, 11:42 PM
            15 responses
            357 views
            1 like
            Last Post PaulMohn  
            Started by PaulMohn, Yesterday, 02:06 AM
            3 responses
            12 views
            0 likes
            Last Post PaulMohn  
            Working...
            X