Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Count bar price levels OnMarketData / On Render

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

    Count bar price levels OnMarketData / On Render

    Hello everyone

    I am working on a script using OnMarketData to collect ask, bid and volume and I use them before in OnRender to calculate delta, volume, etc...
    Now, I would like to count the number of price levels in each bar (range).

    Any idea how can I get this?

    Thanks in advanced

    #2
    Hello Rosario,

    Thank you for your post.

    You could loop through High[0] and Low[0] by TickSize within OnMarketData() and count the price levels within the range of a bar. For example, the loop would look something like this.

    Code:
    if(marketDataUpdate.MarketDataType == MarketDataType.Last)
    {
    
        int count = 0;
        for (double i = High[0]; i >= Low[0]; i -= TickSize)
        {
            count++;
        }
        Print(CurrentBar + " High[0] " + High[0] + " Low[0] " + Low[0] + " count: " + count);
    }
    See the attached example script which demonstrates how to accomplish this.

    Also, see the help guide documentation below for more information.
    OnMarketData() - https://ninjatrader.com/support/help...marketdata.htm
    TickSize - https://ninjatrader.com/support/help...t_ticksize.htm

    Let us know if we may assist further.
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    566 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X