• 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 Miguel_88, Today, 06:41 PM
        0 responses
        5 views
        0 likes
        Last Post Miguel_88  
        Started by spikeruk, Today, 01:49 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by Yandychang, Today, 02:16 PM
        5 responses
        18 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by priceisking, Today, 01:16 PM
        2 responses
        8 views
        0 likes
        Last Post priceisking  
        Started by kashyapjdave, 03-23-2017, 12:12 AM
        11 responses
        1,959 views
        0 likes
        Last Post forextrader2003  
        Working...
        X