• 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 leodrz, Yesterday, 09:45 PM
        2 responses
        14 views
        0 likes
        Last Post leodrz
        by leodrz
         
        Started by habibalex, Yesterday, 09:30 PM
        0 responses
        8 views
        0 likes
        Last Post habibalex  
        Started by Herrwolf1, Yesterday, 09:07 PM
        0 responses
        8 views
        0 likes
        Last Post Herrwolf1  
        Started by nomadmilo, Yesterday, 08:52 PM
        1 response
        9 views
        0 likes
        Last Post nomadmilo  
        Started by jvanelli, Yesterday, 08:48 PM
        2 responses
        10 views
        0 likes
        Last Post jvanelli  
        Working...
        X