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 Mokaru Zen, Today, 01:20 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by dgee949, Yesterday, 06:26 PM
    1 response
    38 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by dgee949, Yesterday, 05:58 PM
    1 response
    40 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by papaoutai, Yesterday, 08:56 AM
    1 response
    42 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by grzltn, Today, 02:18 AM
    0 responses
    21 views
    0 likes
    Last Post grzltn
    by grzltn
     
    Working...
    X