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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    63 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    91 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    48 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    105 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    63 views
    0 likes
    Last Post PaulMohn  
    Working...
    X