Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Try / catch block in NT8 reference indicator - SpreadOscillator

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

    Try / catch block in NT8 reference indicator - SpreadOscillator

    NT Forum,

    A quick thank you to NinjaTrader_Paul for the NT8 reference indicator: NT8 - Spread Oscillator. I am grateful the indicator has been posted for reference.

    The indicator uses a try/catch block for a critical section of the logic in OnBarUpdate(). While this approach works, how could the indicator be re-written without the try/catch block?

    It is my understanding exceptions should only be used when an application encounters an exceptional circumstance (MSDN). The basic rule of thumb for catching exceptions is to catch exceptions if and only if you have a meaningful way of handling them (StackOverflow). Using exceptions gratuitously is where you lose performance. For example, you should stay away from things like using exceptions for control flow (StackOverflow).

    Could IsValidDataPoint() be used?

    As always, any suggestions are welcome

    Regards
    Shannon
    Attached Files

    #2
    Hello Shansen,

    Thanks for your post.

    I did not create the indicator but converted it from the NT7 version which included the try/catch blocks.

    Doing some historical research the use of the try/catch blocks, in this case, were from initial development of the indicator and are really not needed as the Ninjascript methods are handled by the core and so the try/catch blocks can be removed. I will add this to my todo list to remove the try/catch blocks and then re-upload to the NT8 indicators forum.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, Yesterday, 10:06 AM
    0 responses
    20 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    18 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    14 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    9 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    38 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X