Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninjatrader Interactive Brokers Instrument USDINR ATTN 03794489

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

    Ninjatrader Interactive Brokers Instrument USDINR ATTN 03794489

    Hi - Is there a way to add an instrument using a Ninjatrader script? The reason is that I am trying to add an instrument USDINR future which is traded on NSE in India and data is being fetched using Interactive Brokers (IB) API. However, the futures contract has weekly expiry. Hence there are four expiration dates in a month and in Ninjatrader instrument you need to specify contract month and rollover date but because of weekly expiry I can't add four rollover dates for a month. Hence, I somehow need a way to specify last trading date. For your reference I am able to fetch data from API using python code below

    def SimpleFuture():
    contract = Contract()
    contract.symbol = "USDINR"
    contract.secType = "FUT"
    contract.exchange = "NSE"
    contract.currency = "INR"
    contract.lastTradeDateOrContractMonth = "20230328"
    contract.multiplier=1000
    return contract​

    #2
    Hello, thanks for writing in and welcome to the NinjaTrader forum. The scripting library does support multi instrument scripts. Please see here for a guide on these:



    To add the data series you use the AddDataSeries() method.

    Ninjascript is a C# based library, so you can use the DateTime.Now method to check what part of the month you are in and then load the required data series for that month.

    Here is a detailed tutorial on C# DateTime class and how to work with dates and times using C#.


    Kind regards,
    -ChrisL​

    Comment


      #3
      Thanks, Chris. Is there some example that you can point me to where someone has tried to load any instrument using this scripting library? Also, it is not clear how will I specify all the metrics of the instrument like the exchange, symbol for Interactive brokers, instrument type, expiry date, etc. when I am trying to fetch the data. if there is an example I will be able to replicate that on my own.
      Last edited by samanruptrader; 03-16-2023, 07:45 AM.

      Comment


        #4
        Hi, The AddDataSeries method does not take parameters such as Exchange or the instrument type. This data is pre-defined in the instrument database. You can add custom instruments through Tools>Instruments. See the documentation on AddDataSeries here and also reference the pre-existing example called "SampleMultiTimeFrame" in the Strategies folder of the NinjaScript Editor:

        Comment


          #5
          Thank you for your responses.

          Please be patient as I describe the issue with the Tools>Instrument window when adding a futures contract. The usual method is to add the contract months and rollover date. For example, for ES (which has quarterly expiration) the contract month is specified as 03-23 with a rollover date of 12-12-2022 and that is how Ninjatrader then gets that data from the relevant data sources when loading ES 03-23 in charts.

          However, in my case, the USDINR future instrument is weekly expiry. I have the following expiry dates 17 March 2023, 24 March 2023, 28 March 2023, and 31 March 2023. Out of these the equivalent monthly expiry date with the most volume is 28 March 2023 which I want to load. Now I can only select one contract month at a time and under that I can specify only one rollover date. How do I add the last expiry date so that Ninjatrader can query and fetch the instrument from IB gateway. If I add 04-23 (to get the next month's contract) with a rollover date of 28 March 2023, even then Ninjatrader is not able to get any data and the error from logs is Error:IB was unable to locate the instrument. Please verify your symbol mapping is correct for instrument USDINR_I 04-23 Nse

          Comment


            #6
            Hi, NinjaTrader will only go down to the Month level for contracts so a weekly contract is not going to be possible to chart out. On this page, though, I am seeing it does have quarterly contracts you can use:
            https://www.nseindia.com/products-se...cification-inr (publicly available)

            Comment


              #7
              Ok, my apologies but then what was the initial response from you referring to? I thought you mentioned there is a way to specify the exact last trading date and override the Tools>Instrument which has limitations. I just want to fetch this particular contract (please see the attachment from TWS). I am 100% sure that all the fields are correctly populated in Tool>Instrument but what do I mention in the contract month section?
              Attached Files

              Comment


                #8
                Hi, I did not see that the instrument has weekly expires which would not be possible since NinjaTrader has not way of specifying the week. It only has months in the contract code. Sorry for the oversight.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                63 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                40 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                21 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                25 views
                0 likes
                Last Post TheRealMorford  
                Started by Mindset, 02-28-2026, 06:16 AM
                0 responses
                51 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Working...
                X