Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Disabling Error Boxes / Checking for Valid Instrument

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

    Disabling Error Boxes / Checking for Valid Instrument

    Hi,

    I'm using

    Code:
    barsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage)
    to request historical data on a different time frame in a market analyzer column, when adding the S&P 500 I receive pop up error boxes for a number of instruments, for example:

    "Error on requesting bars series: 'The instrument for which you requested data is invalid: NU'"

    and then

    "Unhanded exception: object reference not to to an instance of an object"

    This is even when using a try catch block.

    Is there a way to disable these errors within Ninjascript or alternately is there a method to check whether an instrument is valid?

    Thanks

    #2
    Have tested this further, appears the errors are thrown for when any custom columns are added to the Market Analyzer and there is no way to catch them.

    For example when I add a much simpler column which checks the open value and doesn't use barsRequest the error box appears this time stating "Error on requesting bar series 'No data available for this request'".

    I've tried to check if the instrument is valid by using Bars.Count > 0 and breaking if not but the above error appears beforehand and the script doesn't continue.

    The pop up error box does not appear when using only the standard market analyzer columns but no data appears which makes me assume the same error has been encountered but it's only thrown if it's a none standard column.

    So, is it possible to disable these error boxes and route all errors to the log instead? They become extremely irritating and sometimes are not possible to close before Ninjatrader crashes.

    Thanks

    Comment


      #3
      Hello tdouglas,

      Thank you for your post.

      I do not believe it is possible to verify the instrument is valid or disable the messages, but I will look into this further.

      Comment


        #4
        Hello tdouglas,

        Thank you for your patience.

        In the OnStateChange() method you can do the following for Configure:
        Code:
        else if (State == State.Configure)
        			{
        				 // this is a bad instrument name just for testing/demonstration
        				 // changing the string to "AAPL" would successfully pass
        				 string instrumentName = "APPLE";
        
        				 MasterInstrument masterInstrument = MasterInstrument.DbGet(instrumentName, InstrumentType.Stock);
        				 
        				 if(masterInstrument != null)
        				  	AddDataSeries(instrumentName, BarsPeriodType.Minute, 1);
        				 
        				 else throw new Exception(instrumentName  + " does not exist");
        			}

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rocketman7, Today, 09:41 AM
        2 responses
        5 views
        0 likes
        Last Post rocketman7  
        Started by traderqz, Today, 09:44 AM
        1 response
        4 views
        0 likes
        Last Post traderqz  
        Started by rocketman7, Today, 02:12 AM
        7 responses
        31 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by guillembm, Yesterday, 11:25 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by junkone, 04-21-2024, 07:17 AM
        10 responses
        150 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X