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 Hexades, Today, 08:15 AM
        0 responses
        2 views
        0 likes
        Last Post Hexades
        by Hexades
         
        Started by Uregon, 05-20-2024, 03:44 AM
        2 responses
        12 views
        0 likes
        Last Post Uregon
        by Uregon
         
        Started by Vigorunning, 05-01-2019, 12:42 PM
        25 responses
        936 views
        2 likes
        Last Post MayDay89  
        Started by ETFVoyageur, 05-26-2024, 08:42 PM
        3 responses
        31 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by LordNoah, Today, 12:19 AM
        3 responses
        20 views
        0 likes
        Last Post LordNoah  
        Working...
        X