• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
      Patrick H.NinjaTrader Customer Service

      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");
        			}
        Patrick H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Zuhier Dourgham, Today, 03:55 AM
        0 responses
        6 views
        0 likes
        Last Post Zuhier Dourgham  
        Started by JorgeDamien, Today, 03:47 AM
        0 responses
        2 views
        0 likes
        Last Post JorgeDamien  
        Started by jefferyfrench, Today, 03:45 AM
        0 responses
        3 views
        0 likes
        Last Post jefferyfrench  
        Started by alberts, Yesterday, 09:50 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by VincentMicah, Today, 12:46 AM
        0 responses
        3 views
        0 likes
        Last Post VincentMicah  
        Working...
        X