• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Type of argument "string" in the dll

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

    Type of argument "string" in the dll

    Hello!
    Trying to work with NTDirect.dll from my C++ RAD2007 application and get exceptions often while trying to call SubscribeMarketData, UnsubscribeMarketData, MarketData.

    What type of arguments should I use for "string", for
    double
    MarketData(string instrument, int type),
    as example?

    I tried to use: AnsiString, std::string, std::wstring and got exception.

    Thanks in advance!


    #2
    second, a regular string should do it - are you sure you get this exception because of the string type used?

    Are you subscribing to MarketData first by calling SubscribeMarketData()?

    http://www.ninjatrader-support.com/H...unctions2.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Are you subscribing to MarketData first by calling SubscribeMarketData()?
      Yes, I did it first.
      My sample code in Borland Builder C++:

      Code:
       
      AnsiString b = "ES 12-09";
      NT = LoadLibrary("NTDirect.dll");
      if (NT) {
          Connected2 = (Connected1 *)GetProcAddress(NT, "Connected");
          SubscribeMarketData2 = (SubscribeMarketData1 *)GetProcAddress(NT, "SubscribeMarketData");
          UnsubscribeMarketData2 = (UnsubscribeMarketData1 *)GetProcAddress(NT, "UnsubscribeMarketData");
          TearDown2 = (TearDown1 *)GetProcAddress(NT, "TearDown");
          MarketData2 = (MarketData1 *)GetProcAddress(NT, "MarketData");
          }
      // Subscribe
      if(SubscribeMarketData2)  SubscribeMarketData2(b);
      Sleep(500);
       
      // Get data
      double s = MarketData2(b, 0);
      Form1->Label1->Caption = s;
      Sleep(500);
      
      // Unsubscribe
      if(UnsubscribeMarketData2) {UnsubscribeMarketData2(b); }
      if(TearDown2) TearDown2();    
      if (NT) FreeLibrary(NT);
      And often I get exceptions, sometimes at SubscribeMarketData, sometimes at MarketData. I was adviced that it might be from using wrong type of argument.
      What language the library was written? Delfi?

      Comment


        #4
        second, sorry not familiar with Borlands C++, but I believe you would need to convert the AnsiString being passed in - http://www.tek-tips.com/viewthread.c...=648627&page=9
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mike Winfrey, Today, 11:27 AM
        0 responses
        1 view
        0 likes
        Last Post Mike Winfrey  
        Started by swcooke, Yesterday, 07:35 PM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by brownsfan019, Today, 10:45 AM
        0 responses
        7 views
        0 likes
        Last Post brownsfan019  
        Started by brownsfan019, Today, 10:41 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by bchip, Today, 09:25 AM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X