Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by PaulMohn, Today, 05:00 AM
    0 responses
    7 views
    0 likes
    Last Post PaulMohn  
    Started by ZenCortexAuCost, Today, 04:24 AM
    0 responses
    6 views
    0 likes
    Last Post ZenCortexAuCost  
    Started by ZenCortexAuCost, Today, 04:22 AM
    0 responses
    3 views
    0 likes
    Last Post ZenCortexAuCost  
    Started by SantoshXX, Today, 03:09 AM
    0 responses
    16 views
    0 likes
    Last Post SantoshXX  
    Started by DanielTynera, Today, 01:14 AM
    0 responses
    5 views
    0 likes
    Last Post DanielTynera  
    Working...
    X