Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MarketData()

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

    MarketData()

    Hi guys,
    Total NT newbie here.

    Im trying to use the ATI to get market data.

    Using a simulator data feed while NT is running.

    Ntdirect.dll loads fine.
    Connected(1) shoes I'm connected.
    SubscribeMarketData("ES 12-11") returns 0 which is supposed to indicate success.

    But, all calls to MarketData("ES 12-11",0) return zero?

    Any ideas?

    Thanks in advance

    Jason

    #2
    Jason, what language are you calling the ATI with? Can you also post the full code you're using so we can get a better look?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Hi Austin.

      Here is the code, called from a console app in VS2010 running on 64bit Windows 7, compiled as 32bit though so it works with the Ntdirect.dll.


      // ninjatest.cpp : Defines the entry point for the console application.
      //

      #include "stdafx.h"
      #include <string>
      #include <windows.h>

      using namespace std;
      int _tmain(int argc, _TCHAR* argv[])
      {
      typedef int (__stdcall *NTCommand)( string command,
      string account,
      string instrument,
      string action,
      int quantity,
      string orderType,
      double limitPrice,
      double stopPrice,
      string timeInForce,
      string oco,
      string orderId,
      string strategy,
      string strategyId);
      typedef int (__stdcall *NTConnected)(int showMessage);
      typedef int (__stdcall *NTFilled)(string orderId);
      typedef double (__stdcall *NTMarketData)(string instrument,int type);
      typedef int (__stdcall *NTMarketPosition)(string instrument,string account);
      typedef string (__stdcall *NTNewOrderId)();
      typedef string (__stdcall *NTOrderStatus)(string orderId);
      typedef int (__stdcall *NTSubscribeMarketData)(string instrument);
      typedef int (__stdcall *NTTearDown)();
      typedef int (__stdcall *NTUnsubscribeMarketData)(string instrument);

      NTCommand Command = NULL;
      NTConnected Connected = NULL;
      NTSubscribeMarketData SubscribeMarketData = NULL;
      NTMarketData MarketData = NULL;
      NTTearDown TearDown = NULL;
      NTUnsubscribeMarketData UnsubscribeMarketData = NULL;

      HINSTANCE NTDLL;
      NTDLL = LoadLibrary(L"c:\\windows\\sysWOW64\\NtDirect.dll" );

      if(NTDLL == NULL)
      return 1;

      Command = (NTCommand)GetProcAddress(NTDLL,"Command");
      Connected = (NTConnected)GetProcAddress(NTDLL,"Connected");
      SubscribeMarketData = (NTSubscribeMarketData)GetProcAddress(NTDLL,"Subsc ribeMarketData");
      MarketData = (NTMarketData)GetProcAddress(NTDLL,"MarketData");
      TearDown = (NTTearDown)GetProcAddress(NTDLL,"TearDown");
      UnsubscribeMarketData = (NTUnsubscribeMarketData)GetProcAddress(NTDLL,"Uns ubscribeMarketData");

      int rtn = Connected(1);
      double last;
      int i = 0;

      //Only do stuff if we are connected.
      if(!rtn)
      {
      //Now lets try and add an order.
      //rtn = Command("PLACE","SIM101","ES 12-11","BUY",5,"MARKET",0,0,"DAY","","ABC","BASIC","" );

      rtn = SubscribeMarketData("ES 12-11");

      if(!rtn)
      {
      for(i = 0;i < 10;i++)
      {
      last = MarketData("ES 12-11",1);
      printf("Last:%.2lf\n",last);
      }

      rtn = UnsubscribeMarketData("ES 12-11");
      rtn = TearDown();
      }
      }

      FreeLibrary(NTDLL);

      return 0;

      Comment


        #4
        jayhay, we don't officially support 3rd party applications using the ATI, but please try inserting some delay statements (>5ms) in your code between subscribing to the data and then requesting the data.
        AustinNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by LawrenHom, Today, 10:45 PM
        0 responses
        3 views
        0 likes
        Last Post LawrenHom  
        Started by love2code2trade, Yesterday, 01:45 PM
        4 responses
        28 views
        0 likes
        Last Post love2code2trade  
        Started by funk10101, Today, 09:43 PM
        0 responses
        7 views
        0 likes
        Last Post funk10101  
        Started by pkefal, 04-11-2024, 07:39 AM
        11 responses
        37 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Yesterday, 08:51 AM
        8 responses
        44 views
        0 likes
        Last Post bill2023  
        Working...
        X