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

Provider specific symbol for instrument

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

    Provider specific symbol for instrument

    How can i get provider specific symbol name for current chart instrument? For example i need get IQFeed @EUM12 for 6E 06-12. I see multiple names in Instrument.MasterInstrument.UserData XML, it could be useful for futures (contains @EU prefix, so i can append expiration date), but for spot has useless value (EURUSD).
    Thank you.

    #2
    Welcome to our forums Jan, unfortunately accessing the symbol map value would not be supported from NinjaScript. You can check into our documented items for the Instruments class though to see what's available here - http://www.ninjatrader.com/support/h...instrument.htm
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thank you for the response.
      I noticed strenge behaviour: when i open new charts for 6E 06-12 and 6E 09-12 (the later seem to be default expiry date for 6E in symbol lookup, why not nearest?) i expected different data, but i got exactly the same quotations. It is by design?
      To avoid this i decided to create my own instruments and handle only them. I need something like futures, but without explicit expiration date: custom tick size, custom point value etc. Is there easy way for import such instrument definitions?
      Thank you.

      Comment


        #4
        Yes, this would be by design, if you wish to access the original contract data for each individual contract, then please set the Merge policy to 'DoNotMerge' for the master instrument under Tools > Instrument Manager.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thank you, i was missing it.
          Next problem: opening chart for custom instrument with custom indicator without any data and with no data provider. I need do some work before indicator starts (in fact i need run external data provider), but in such case no OnStartUp won't be called, neither OnBarUpdate nor OnMarketData. Is there any way to do something only once for indicator beside implementing this in Initialize and using flag for indicating startup done (Initialize can be called many times)?

          As i see this doesn't work too. I gather my own logs and after changing indicator and reloading the chart i see this:
          Code:
          2012-05-15 17:11:33 constructor
          2012-05-15 17:11:33 constructor
          2012-05-15 17:11:33 constructor
          2012-05-15 17:11:33 initialize doneFlag=False
          2012-05-15 17:11:33 constructor
          2012-05-15 17:11:33 initialize doneFlag=False
          2012-05-15 17:11:33 constructor
          2012-05-15 17:11:33 initialize doneFlag=False
          2012-05-15 17:11:33 constructor
          2012-05-15 17:11:33 initialize doneFlag=False
          After F5 i see this:
          Code:
          2012-05-15 17:11:43 constructor
          2012-05-15 17:11:43 constructor
          2012-05-15 17:11:43 initialize doneFlag=False
          doneFlag is set right after debug line in Initialize.
          There is only 1 chart and only 1 indicator...
          Calling OnStartUp always would be solved problems many people (not only mine), is there any magic trick?
          Thank you.

          EDIT: I cannot access Instrument property in Initialize, OnstartUp and thers are not called. How can i get chart instrument data?
          Last edited by 0.jan.nowak; 05-15-2012, 09:32 AM.

          Comment


            #6
            Unfortunately there would be no other supported method I could point you - you would need to have data to have OnStartUp() or the first OnBarUpdate() bar called, from here you could access the Instrument info as the chart would then be guaranteed to have a bars object.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thank you for the response.
              OnStartUp and OnBarUpdate will be called if data will be provided.
              Data will be provided if OnStartUp or OnBarUpdate will be called.
              So empty chart will never be filled with data...
              Last hope: external application as data feeder (using NTDirect.dll).

              Comment


                #8
                This would be an option, yon can drive market data to an NT symbol via an external application with the Last function in the NtDirect.dll

                For getting data on your chart to use those methods, you can also consider importing historical data for your custom symbol in NT's Historical Data Manager.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  "Funny" thing is that i cannot import NTDirect.dll into VS project. This ddl isn't registered as a COM neither cannot be registered (i tried both regsvr32.exe: from system32 and syswow64 folders). I checked all NTDirect.dll files in folders:

                  c:\Windows\System32\
                  c:\Windows\SysWOW64\
                  c:\Program Files (x86)\NinjaTrader 7\bin\
                  c:\Program Files (x86)\NinjaTrader 7\bin64\

                  All files are exactly the same! File has length 86.016 bytes, MD5 is 79d305f7b1fdfe567b4157fff5298047. Shouldn't there be byte difference between x86 and x64 versions?
                  NT version is 7.0.1000.10

                  EDIT:
                  This code seems to work:
                  Code:
                  using System;
                  using System.Collections.Generic;
                  using System.Linq;
                  using System.Text;
                  using System.Runtime.InteropServices;
                  
                  namespace Nemesis.NinjaTreader.Feeder {
                      class Program {
                          [STAThread]
                          static void Main(string[] args) {
                              string s = "NEURUSD";
                              x86.x(s);
                              x64.x(s);
                              Console.ReadLine();
                          }
                      }
                  
                      public class x86 {
                          [DllImport(@"c:\windows\system32\ntdirect.dll")]
                          static extern int Ask(string instrument, double price, int size);
                          [DllImport(@"c:\windows\system32\ntdirect.dll")]
                          static extern int Bid(string instrument, double price, int size);
                          [DllImport(@"c:\windows\system32\ntdirect.dll")]
                          static extern int Last(string instrument, double price, int size);
                          [DllImport(@"c:\windows\system32\ntdirect.dll")]
                          static extern int Connected(int showMessage);
                  
                          public static void x(string s) {
                              Console.WriteLine(Ask(s, 1.23, 3));
                              Console.WriteLine(Bid(s, 1.24, 4));
                              Console.WriteLine(Last(s, 1.25, 5));
                              Console.WriteLine(Connected(0));
                          }
                      }
                  
                      public class x64 {
                          [DllImport(@"c:\windows\syswow64\ntdirect.dll")]
                          static extern int Ask(string instrument, double price, int size);
                          [DllImport(@"c:\windows\syswow64\ntdirect.dll")]
                          static extern int Bid(string instrument, double price, int size);
                          [DllImport(@"c:\windows\syswow64\ntdirect.dll")]
                          static extern int Last(string instrument, double price, int size);
                          [DllImport(@"c:\windows\syswow64\ntdirect.dll")]
                          static extern int Connected(int showMessage);
                  
                          public static void x(string s) {
                              Console.WriteLine(Ask(s, 1.23, 3));
                              Console.WriteLine(Bid(s, 1.24, 4));
                              Console.WriteLine(Last(s, 1.25, 5));
                              Console.WriteLine(Connected(0));
                          }
                      }
                  }
                  but Connected always returns -1.
                  At last any progress..
                  Last edited by 0.jan.nowak; 05-16-2012, 12:51 AM.

                  Comment


                    #10
                    Is the AT interface on NT then checked? This would be found under the File menu and 'opens' NT up for external connections.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Yes, that was missing, thanks. And of course defining symbol for 'External' broker.

                      Now anly find a way to import historical data without manual import
                      Thanks again.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by algospoke, Today, 06:40 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post algospoke  
                      Started by maybeimnotrader, Today, 05:46 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post maybeimnotrader  
                      Started by quantismo, Today, 05:13 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post quantismo  
                      Started by AttiM, 02-14-2024, 05:20 PM
                      8 responses
                      167 views
                      0 likes
                      Last Post jeronymite  
                      Started by cre8able, Today, 04:22 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post cre8able  
                      Working...
                      X