Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question on BarsPeriodType.Minute

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

    Question on BarsPeriodType.Minute

    Hi,

    I see in the documentation: https://ninjatrader.com/support/help...?builtfrom.htm
    that when build from BarsPeriodType.Minute, the onDataPoint() is updated every minute. Does this mean it updates every whole minute, for ex. 3:30, 3:31 etc. Or does the minute start from when it is added to the chart?


    #2
    Hello admiralpanda,

    The BuiltFrom means the custom bar type will be loading historical minute data for calculations and not historical tick data.

    The bar starts from the start of the whole minute based on the time stamps of the data.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      So, this is just for Historical data or Real time data too?
      Because even though I used BarsPeriodType.Minute, I still see the bars updating on each tick instead of updating after each minute.

      Comment


        #4
        Hello admiralpanda,

        The BuiltFrom specifies how the historical data is loaded. In real-time OnDataPoint will be updating for every tick (to adjust the High, Low, Close prices as the bar builds).
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Got it. Thank you!

          Comment


            #6
            Hello Chelsea ,
            Is there a way that we can configure the OnDataPoint function to be called for every Minute instead of on every tick.

            Thanks,
            Sridhar M

            Comment


              #7
              Hello Sridhar,

              Welcome to the NinjaTrader forums!

              Unfortunately this would not be possible. The OnDataPoint() has to run for every tick to know if the bar needs to be updated.
              You don't have to call UpdateBar() or AddBar() though. You can skip running the logic you want.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hi Chelsea,
                Thanks for the reply.

                As per your suggestion, i have made changes to my code to run the bar updating logic for every 1 minute. However, the chart get stuck infinitely after being responsive for some time.
                While i close the chart i could see this error " Unhandled Exception. Write lock may not be acquired with read lock held. This pattern is prone to deadlocks."
                Please let me know what could be the best solution.


                protected override void OnDataPoint(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isBar, double bid, double ask)
                {

                //This code is added to run the bar logic for every 1 minute
                if (g_processed_minute == time.Minute){
                return;
                }
                else{
                g_processed_minute = time.Minute;
                }​

                //--------------------------------------------------------
                // Bar updation/ Bar addition logic goes below.....

                }

                Thanks,
                Sridhar M
                Last edited by s1r9i7d5har; 06-14-2024, 12:00 PM.

                Comment


                  #9
                  Hello Sridhar,

                  There might be something else in the code of the script that is causing issues.

                  I've tested the code you provided with the Playback connection and it appears to be working as expected.

                  Below is a link to a video of the test.


                  Attached is the test script.
                  SridharTest.cs

                  Can you reproduce on your end using this test script I've supplied and following the steps shown in the video?
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  673 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  379 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  111 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  577 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  582 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X