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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    672 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    379 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    111 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    577 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    582 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X