Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Developing Tick Based Indicators

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

    Developing Tick Based Indicators

    Good day,

    I am developing a tick based indicator and want to verify what I have learned so far as well as to ask a question or two.

    First, the following is what I have learned so far. Please verify that the following is true:

    1) All indicator code should go into the OnBarUpdate() method.

    2) In the Initialize() method, set CalculateOnBarClose to false so that the OnBarUpdate() method is called for each tick.

    3) GetCurrentBid(), GetCurrentAsk(), GetCurrentBidVolume(), GetCurrentAskVolume() return the most recent values for each of these items and are OK to call for each tick.

    4) The current tick price is the value in the Close[0] data series. This is the price of the last trade or the most recent price. So ...
    double tickPrice = Close[0];
    will assign to tickPrice the transaction price of this tick. And because it is in Close[0] it is the latest, most recent, or last price.

    5) FirstTickOfBar() will be true when OnBarUpdate() is called for the first tick of a new bar.

    6) Volume[0] returns the cumulative volume for the current bar. It is a running total that is reset at the start of each new bar. To determine the tick volume, we can use FirstTickOfBar() and Volume[0] like this:
    double lastVolume;
    double tickVolume;

    if (FirstTickOfBar() == true)
    {
    lastVolume = 0;
    }

    tickVolume = Volume[0] - lastVolume;
    lastVolume = Volume[0];

    7) Time[0] returns the time of the current bar. Its finest granularity is one minute. It is changed at the start of each new bar (when FirstTickOfBar() is true).

    --------

    Please confirm that the preceding is correct.


    Now for a question:

    So far the only transaction time I have found is Time[0], the start time of the current bar. I have been unable to find a way to determine the time of the current tick.

    Is there a way to determine the time of the current tick?


    Thank you.

    #2
    oznog,

    Yes, everything you wrote looks correct.

    As far as your question, you could use several options here.

    OnBarUpdate() will be called for each tick. So you could use something like : DateTime.Now for the time stamp of the last time OnBarUpdate() was called.



    You can also use OnMarketData() and get the time stamp.

    OnMarketData() : http://www.ninjatrader.com/support/h...marketdata.htm

    MarketDataEventArgs : http://www.ninjatrader.com/support/h...aeventargs.htm

    Finally, you could use a 1 tick data series in a multi-series indicator to get the Times[X][0] of the most current tick.



    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hello AdamP,

      Thanks for your suggestions. I used DateTme.Now to get the tick time. It seems to give good results.

      Another question ....

      Is there a way to control the number of bars displayed on a chart from within a NinjaTrader script?

      Thank you.

      Comment


        #4
        Hello,
        You can simply color the bars transparent and make them invisible. But the bars will still be there.


        If you want to remove certain bar/bars then you can create a custom BarType. Unfortunately we do not support custom BarType but you can refer to the @BarsType.cs file in the folder <My Documents>\NinjaTrader 7\bin\Custom\Type\
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        596 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        554 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X