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

programmatically determine if a particular Instrument is being provided

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

    programmatically determine if a particular Instrument is being provided

    This raises an interesting point.

    In an AddOn, is there any way (supported or unsupported) to programmatically determine if a particular Instrument is being provided by a particular Account/Connection?

    For example, if I connect to an FXCM Account, can I discover, or alternatively, can I query, if a particular currency pair (e.g. USDTRY) is actively in the data stream? [Note: this is just an example -- it could be any broker, any Instrument type, any Instrument.]

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    One way would be to do a BarsRequest over a small data sample and look at the errorMessage / errorCode returned, and check if the data was returned.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Perhaps try the undocumented method,

      MasterInstrument.DbGet(string name, InstrumentType type)

      It returns a reference to a MasterInstrument, which, may be null if the
      instrument is (I think) not supported. The point here just might be to
      check for the null return ... that might be enough.

      Comment


        #4
        Perhaps I need to clarify my question. Suppose I have an Account with a broker and that Account is subscribed to various Instruments, but not subscribed to various other Instruments. When I connect to the Account, data should flow for the Instruments I am subscribed to, but not for the Instruments for which I am not subscribed. If I know the valid Instruments for the Account (i.e. Instruments which can be subscribed to), how can I determine from the Account or Connection in real-time what Instruments are actually supplying data (in other words, the ones subscribed to), without needing to go to an external source to determine if a particular Instrument is subscribed to or not?

        For example, an FXCM Account may be subscribed to the 28 major Forex pairs, but may or may not be receiving the exotics. How can one programmatically determine in an AddOn if a valid Instrument is expected to receive data or not? If I select EURUSD as the Instrument, all is fine. If I select XAUUSD as the Instrument, the BarsRequest does not have any errors, but there is no data. This is somehow recognised in a standard Basic Entry window, where selecting an Instrument that is not receiving data will display as "n/a" in the pricing displays. That means it must be possible programmatically to identify this. How?

        Thanks.
        Multi-Dimensional Managed Trading
        jeronymite
        NinjaTrader Ecosystem Vendor - Mizpah Software

        Comment


          #5
          Hello jeronymite,

          To confirm, the barsRequest did not provide an errorMessage and was able to return data for instruments you do not have a subscription for?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            No. The BarsRequest did not return an error when requesting an Instrument that is not providing data, and there was indeed no data provided. The BarsRequest completed without error, but then no data ever arrives. This is despite the Instrument being within market trading hours, and other similar Instruments streaming data as expected.

            So, Basic Entry recognises when a valid Instrument is not providing data, but BarsRequest cannot identify this condition. The question remains, if Basic Entry can distinguish when there will be no data for a particular Instrument, how can this same condition be recognised in an AddOn?

            Thanks.
            Multi-Dimensional Managed Trading
            jeronymite
            NinjaTrader Ecosystem Vendor - Mizpah Software

            Comment


              #7
              Hello jeronymite,

              The BarsRequest not retrieving data would tell you that there is no data for the instrument.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thanks, NinjaTrader_ChelseaB ... I wish it were definitive ... but it is not.

                No data will be received if outside of market hours. Even during market hours, data may not be received for a significant period of time if the Instrument is low volume. These conditions can happen to any subscribed Instrument.

                So, "no data" is not readily identifiable as "data not being provided" (which may align with not subscribed).

                The Instrument property HasSeenMarketData may be useful, but again, until such time as market data is actually received, it should be false. That would be the case, presumably, for the two conditions above. And since some providers do not provide historical data for every Instrument, one cannot rely on the presence of historical data as an indicator of "data will arrive eventually".

                In any case, as already mentioned, Basic Entry seems to be able to immediately identify that an Instrument will not receive data as soon as it is selected. Therefore, it is possible in code to identify the case of "will never receive data (in the current configuration)" as opposed to "has not yet received any data, but should when data is available". How is this distinction made in that code?

                Thanks.
                Last edited by jeronymite; 03-03-2023, 02:54 PM.
                Multi-Dimensional Managed Trading
                jeronymite
                NinjaTrader Ecosystem Vendor - Mizpah Software

                Comment


                  #9
                  Hello jeronymite,

                  I am not aware of a way to determine why no data is available, only how to determine if data is available.

                  I would be happy to submit a feature request for the development team to consider this for a future release if you would like.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks, NinjaTrader_ChelseaB. I would appreciate that.

                    Thanks.
                    Multi-Dimensional Managed Trading
                    jeronymite
                    NinjaTrader Ecosystem Vendor - Mizpah Software

                    Comment


                      #11
                      Hello jeronymite,

                      This request is being tracked with ID # SFT-5794.

                      Please note, we receive many requests and cannot reasonably implement all requested features or changes. Interest is tracked internally and if enough interest is tracked, it would be weighed against how feasible it would be to make those changes to consider implementing, so we cannot offer an ETA or promise of fulfillment.

                      When new features are implemented, they will be listed in the Release Notes page of the Help Guide. The ID number may be different than the internal feature request tracking ID, but the description of the feature will let you know if that feature has been implemented.

                      Release Notes - https://ninjatrader.com/support/help...ease_notes.htm
                      Chelsea B.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by futtrader, 04-21-2024, 01:50 AM
                      4 responses
                      41 views
                      0 likes
                      Last Post futtrader  
                      Started by Option Whisperer, Today, 09:55 AM
                      1 response
                      11 views
                      0 likes
                      Last Post bltdavid  
                      Started by port119, Today, 02:43 PM
                      0 responses
                      1 view
                      0 likes
                      Last Post port119
                      by port119
                       
                      Started by Philippe56140, Today, 02:35 PM
                      0 responses
                      3 views
                      0 likes
                      Last Post Philippe56140  
                      Started by 00nevest, Today, 02:27 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post 00nevest  
                      Working...
                      X