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 joostb, Today, 04:40 AM
    0 responses
    5 views
    0 likes
    Last Post joostb
    by joostb
     
    Started by Johnny Santiago, Today, 03:11 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by pjsmith, Today, 12:44 AM
    2 responses
    23 views
    0 likes
    Last Post pjsmith
    by pjsmith
     
    Started by Liquidfusion, Yesterday, 10:51 PM
    3 responses
    45 views
    0 likes
    Last Post Liquidfusion  
    Started by jjanguda, Yesterday, 10:57 PM
    1 response
    33 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Working...
    X