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

Exception in Ninjatrader core code

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

    Exception in Ninjatrader core code

    Hello,

    I've run the debugger on this many times in a few different pieces of code.

    If you use a line such as the following in OnRender, eventually, you will get an index not found exception

    PHP Code:
    stationaryXpos chartControl.GetXByBarIndex(ChartBars, !Bars.IsTickReplay ChartBars.FromIndex fbtp); // This occasionally causes an exception, yet is OK when in break mode! 
    If you run the code in a debugger, NT will break on the exception. Drilling down, the exception comes from NT8 internal code, not a third party (or mine). What I mean by OK in break mode, is you can print the content of every single variable in that line of code in the immediate window and NOT get any exceptions.

    So, the question is, what is unsafe about using this code in OnRender? Is it not valid to access the Bars or ChartBars objects inside OnRender? (That is where I see the issue quite regularly). Obviously, I am unable to debug this further as the exception is in the NT code, which is not available to me. Wrap it in a Try /Catch and ignore the event when it randomly occurs, and all is well, but that really is not a very good solution.

    Thanks.
    Last edited by pjsmith; 07-22-2023, 05:19 AM.

    #2
    Hello pjsmith,

    Thanks for your post.

    Please send me a simple reduced exported script that demonstrates the behavior you are reporting and send me the exact steps and settings you use to reproduce the behavior.

    I will use the example script and steps you detail to try and reproduce the behavior on my end and investigate this matter further.

    Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue and no third-party scripts. All other code is commented out or removed. To create a copy of your script to modify, open a New > NinjaScript Editor, select your script, right-click in the Editor, select 'Save as', name the script, and click OK.​

    To export a NinjaScript, go to Tools > Export > NinjaScript AddOn.

    Exporting: https://ninjatrader.com/support/help...scriptAsSource Files
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,404 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    95 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    7 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    159 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    8 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X