Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars GetHigh showing errors sometimes

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

    Bars GetHigh showing errors sometimes

    Hi,
    I am using Bars.GetHigh(CurrentBar - 1)
    But maybe once a day I get an error saying this
    "Object reference not set to an instance of an object"
    Can someone please let me know how can I avoid this!

    #2
    Hello PWillard,

    Thank you for writing in.

    The error is advising that something you are accessing has not been created at the time you are accessing it.

    If you are wanting to get the High value of the previous bar, you could use High[1] instead of Bars.GetHigh(Currentbar - 1).

    See this help guide link for more information - https://ninjatrader.com/support/helpGuides/nt8/high.htm

    Ultimately, to understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Below is a link to a forum post that demonstrates using prints to understand behavior and including a link to a video recorded using the Strategy Builder.
    https://ninjatrader.com/support/foru...121#post791121

    Please let me know if I may further assist
    <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
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 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
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X