Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddBar with Error: Write Lock may not be acquired with read lock held.

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

    AddBar with Error: Write Lock may not be acquired with read lock held.

    Greetings!
    Your help would certainly be appreciated.
    This is my first experience with AddBar; perhaps the syntax is incorrect. The script compiles well.
    I trade Tick bars but want to capture Time specific intrabar events – this example script is to retain the precise 9:30 price value which is accurately define as p930, but changes when the screen is refreshed (as is expected with Tick bars).

    Bars.AddBar( p930, p930+(2*TickSize), p930-(2*TickSize), p930, DateTime.Now,
    (long) Math.Min(Volume[1],Volume[2]), TickSize);

    I’ve read all Forum notes regarding this specific log displayed error – Upgradable Lock. In his 3/13/2017 post, Brett comments:

    If anyone else is running into Upgradable lock error message issue I would love to send you a custom build to make sure it will resolve the issue for you so we make sure we have this one squashed.


    This error is outside of my area of understanding or further Forum research. Thanks in advance. I am using NinjaTrader version 8.0.20.1 64-bit.
    Last edited by JulieC; 12-25-2019, 10:20 PM. Reason: Included NinjaTrader version

    #2
    Hi JulieC, thanks for your post.

    AddBar() is only used in custom bar types to add a new bar to the price series. It looks like your doing this from an indicator. To get a price at a certain time you will need to add a second price series to your script. There is a guide on multi-series scripts here:



    In your case, if the script runs OnBarClose, you can add a 1-minute series and capture the price at the close of the 9:30 bar. e.g.

    Code:
    OnBarUpdate()
    {
    
        if(BarsInProgress == 1)
        {
    
            if (Times[1][0].TimeOfDay == new TimeSpan(9, 30, 0))
                {
                    Print(Closes[1][0]);
                }
    
        }
    
    }
    Please let me know if I can assist any further.

    Comment


      #3
      Thanks ChrisL for your help.

      I have no problem extracting the precise price at the precise second/instant – intrabar, within a TickBar.
      The problem is retaining that much precision should a refresh be used.
      Yes, I agree, the suggestion recommended in your response is one good solution (but cumbersome from other aspects). I was hoping to slip in an extra bar without consequence

      I will research more about custom bar types.
      Thanks again.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      68 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      151 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      100 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      288 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X