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

How to Handle BarsRequest Errors?

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

    How to Handle BarsRequest Errors?

    I'm using BarsRequest in an Add On procedure that I've developed, and I'm handling BarsRequest errors as demonstrated in the NT8 Help Guide topic for BarsRequest, as in...

    barsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) =>
    {
    if (errorCode != ErrorCode.NoError)
    {
    // Handle any errors in requesting bars here
    NinjaTrader.Code.Output.Process(string.Format("Err or on requesting bars: {0}, {1}",
    errorCode, errorMessage), PrintTo.OutputTab1);
    return;
    }

    etc.

    I've discovered that this approach to handling errors produced by the Request method doesn't work. It doesn't work, because when the Request method encounters an error the "if (errorCode != ErrorCode.NoError)" code snippet doesn't execute. Instead, NT immediately issues an error that reads like "Error on requesting bars series: 'The instrument for which you requested data is invalid.'" and NT exits the procedure. So, might you recommend another approach for trapping and handling errors produced by the Request method?

    #2
    Hello NtFan,

    Thank you for the post.

    Do you have a specific sample that demonstrates the problem? If you can copy/paste the total BarsRequest logic you used into a test indicator and attach that it would be helpful. Also what are the specific steps to see the error? Are you running this against an instrument that does not exist or what is the specific situation? If the case is that this is an error and it is not being reported as an error I can likely report that to development with a sample/steps to see that.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ScottWalsh, 04-16-2024, 04:29 PM
    6 responses
    27 views
    0 likes
    Last Post ScottWalsh  
    Started by frankthearm, Today, 09:08 AM
    10 responses
    35 views
    0 likes
    Last Post frankthearm  
    Started by GwFutures1988, Today, 02:48 PM
    0 responses
    2 views
    0 likes
    Last Post GwFutures1988  
    Started by mmenigma, Today, 02:22 PM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by NRITV, Today, 01:15 PM
    2 responses
    9 views
    0 likes
    Last Post NRITV
    by NRITV
     
    Working...
    X