Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetCurrentAskVolume and GetCurrentBidVolume have always the same size in replay

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

    GetCurrentAskVolume and GetCurrentBidVolume have always the same size in replay

    Hello NinjaTrader community!

    A few days ago I started implementing my custom strategy from another Broker to NinjaTrader. I'm still very new to the editor and I'm always learning something new. Now I got stuck at a problem that I can't seem to solve.

    Please correct me if I'm wrong here.

    I have two time frames in my strategy. 1. 1-Tick resolution and 2. 1-Minute resolution. I add the strategy to a 1 min chart so I added a tick data series to the state.Configure.

    Code:
    else if (State == State.Configure)
                {
                    AddDataSeries(BarsPeriodType.Tick, 1);
                }​

    On the OnBarUpdate I want to add the ask and bid size to a dictionary. On both minute and tick resolution the ask and bid size is the same size. Why is that?

    Code:
    if (BarsInProgress == 1) //tick resolution
                {
                    //logic
                    
                    Print("ask: " + GetCurrentAskVolume(1));
                    Print("bid: " + GetCurrentBidVolume(1));
                   
                    
                }​

    Is it because of replay or did I do something wrong here? Not only it happens on tick resolution but also on minute resolution.

    Best regards,
    Nico

    #2
    Hello startfrom0,

    Because you are adding a secondary tick series already and also want to add the volumes to a dictionary I would suggest to just use another secondary series for each of the ask and bid series. That would let you see each ask and bid event so you can do operations with that data.

    Comment


      #3
      Hey NinjaTrader_Jesse,
      thank you very much for answering after digging some time in the documentation I implemented said thing and it worked. Thank you!
      I still got one question, if my chart resolution is minutly the BarsInProgress should be 0 right? Because right now every time it enters the 1minute series print statemets that i have placed there fire each tick. I added another 1 minute time series and added the print statements there but it still fires each tick.
      How do I solve this problem?

      Best regards,
      Nico

      Comment


        #4
        Hello startfrom0,

        The series you apply the script to is always BarsInProgress 0, each AddDataSeries that you use will increment the BarsInProgress by 1 for each added series.

        In the code you provided your condition is checking BarsInProgress == 1 so that should print for each 1 tick. You would need to make your code like the following to print once per minute:
        Code:
        if (BarsInProgress == 0) // Chart series
        {
           // print based on primary bar closes
        }​​
        if (BarsInProgress == 1) // first AddDataSeries statement
        {
        
        }​​
        if (BarsInProgress == 2) // second AddDataSeries statement
        {
        
        }​​


        Keep in mind if you are using OnEachTick calculation in realtime then BarsInProgress == 0 is also going to be called once per tick.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        52 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        43 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        48 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X