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

GetInstrument(...) throws 50 errors

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

    GetInstrument(...) throws 50 errors

    Any ideas why I'm getting 50 error dialogs on my screen when calling...

    if(Instrument.GetInstrument(symbol) != null)
    AddDataSeries(symbol, Data.BarsPeriodType.Minute, 1);​


    Click image for larger version

Name:	Untitled.png
Views:	21
Size:	66.3 KB
ID:	1316671

    #2
    Hello defa0009,

    Thank you for your post.

    It looks like you are passing a variable to AddDataSeries(). Please note that AddDataSeries() should not be used dynamically and is not supported to be used in this way:

    "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided.​"



    If you hardcode the AddDataSeries() call, are you still getting this error?
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Not ideal but I'll trying hard coding.
      Last edited by defa0009; 09-04-2024, 03:13 PM.

      Comment


        #4
        Do I need to call AddDataSeries("EURUSD") if I'm going the unmanaged route... which would be at the account level? All Instruments should already be available at the account level correct? Can I just do...

        Instrument instrument = Instrument.GetInstrument("EURUSD");

        Comment


          #5
          If you are using the Unmanaged Approach in a strategy script (i.e. using SubmitOrderUnmanaged()) then you still need to use AddDataSeries() to actually pull in the data.

          GetInstrument is returning the instrument object but isn't actually pulling in any data for the strategy to calculate.
          Gaby V.NinjaTrader Customer Service

          Comment


            #6
            I'm using the addon approach CreateOrder(...)

            Comment


              #7
              Hello,

              In that case, yes, you could simply use Instrument to pass into CreateOrder() as the instrument you're submitting the order to.
              Gaby V.NinjaTrader Customer Service

              Comment


                #8
                Ok thanks...that made it way more simple and all those errors went away.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by dallasstarsfan, Today, 06:04 PM
                0 responses
                2 views
                0 likes
                Last Post dallasstarsfan  
                Started by FBraun, Today, 01:42 PM
                2 responses
                9 views
                0 likes
                Last Post FBraun
                by FBraun
                 
                Started by john_44573, Today, 12:55 PM
                4 responses
                29 views
                0 likes
                Last Post john_44573  
                Started by IDumpedCinderella, Today, 07:39 AM
                4 responses
                19 views
                0 likes
                Last Post IDumpedCinderella  
                Started by defa0009, Today, 09:33 AM
                10 responses
                24 views
                0 likes
                Last Post defa0009  
                Working...
                X