С++ API using NtDirect.dll doesn`t work - futures io
futures io

С++ API using NtDirect.dll doesn`t work

Discussion in NinjaTrader

    1. trending_up 668 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 2 attachments

Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

Search this Thread

С++ API using NtDirect.dll doesn`t work

(login for full post details)
  #1 (permalink)
Posts: 1 since Jun 2018
Thanks: 0 given, 0 received

Good day!
I`m trying to make an application in C++ something like API, working with Ninja Trader 8, using NtDirect.dll, where all c++ functions are realised.
I wrote code, which is very similar with code of API in C#.

To work with functions from NtDirect.dll i explicit link it and get all functions i need.
But something isn`t working.

For example, i made a function, which is called MarketData (it`s supposed to get the last price of the instrument). But when i try to use it, it returns 0 but not the prize.

Everything is fine, everything compile, no it doesn`t throw any exception, but the program still doesn`t give me right numbers.

Please, help me to make this code work (return right numbers).

/* Fields in my class:
typedef  int(*command_func)(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(*connected_func)(int showMessage);
    typedef int(*subscribe_market_data_func)(string instrument);
    typedef int(*unsubscribe_market_data_func)(string instrument);
    typedef double(*market_data_func)(string instrument, int zero);
    typedef int(*tear_down_func)();

    tear_down_func TearDown;
    connected_func Connected;
    command_func Command;
    subscribe_market_data_func SubscribeMarketData;
    unsubscribe_market_data_func UnsubscribeMarketData;
    market_data_func MarketData;

void ClientClass::LoadDLL()
    HMODULE nt_lib;

    nt_lib = LoadLibrary(L"NtDirect.dll");
    if (nt_lib == NULL)
        throw exception("Couldn`t load dll. Error code : ");

    Command = (command_func)GetProcAddress(nt_lib, "Command");
    if (!Command)
        throw exception("Couldn`t load dll`s function (Command). Error code :");

    Connected = (connected_func)GetProcAddress(nt_lib, "Connected");
    if (!Connected)
        throw exception("Couldn`t load dll`s function (Connected). Error code : ");

    SubscribeMarketData = (subscribe_market_data_func)GetProcAddress(nt_lib, "SubscribeMarketData");
    if (!SubscribeMarketData)
        throw exception("Couldn`t load dll`s function (SubscribeMarketData). Error code : ");

    MarketData = (market_data_func)GetProcAddress(nt_lib, "MarketData");
    if (!MarketData)
        throw exception("Couldn`t load dll`s function (MarketData). Error code : ");

    UnsubscribeMarketData = (unsubscribe_market_data_func)GetProcAddress(nt_lib, "UnsubscribeMarketData");
    if (!SubscribeMarketData)
        throw exception("Couldn`t load dll`s function (UnSubscribeMarketData). Error code : ");

    TearDown = (tear_down_func)GetProcAddress(nt_lib, "TearDown");
    if (!TearDown)
        throw exception("Couldn`t load dll`s function (TearDown). Error code : ");

    int connected = Connected(1);
    if (connected)
        throw exception("Error with function Connected. Error code :");
//This function must return the last prize

double ClientClass::GetInstrument(string instrument)
    int connect = Connected(1);
        throw exception("Error with function Connected. Error code :");
    int subscribe = SubscribeMarketData(instrument);
    if    (subscribe)
        throw exception("Error with function SubscribeMarketData. Error code :");

    /* Отладочная печать, она не нужна.
    printf("Connected %d \n", connected);
    printf("Subscribe %d \n", subscribe);
    printf("Unsubscribe %d \n", unsubscribe);
    double lastPrice = MarketData(instrument, 0);

    int unsubscribe = UnsubscribeMarketData(instrument);
    if (unsubscribe)
        throw exception("Error with function UnsubscribeMarketData. Error code :");
    return lastPrice;

Attached Files
Register to download File Type: zip Test.zip (21.4 KB, 5 views)
Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(90 thanks from 14 posts)
looks_twoSalao's Journalby Salao
(31 thanks from 7 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(26 thanks from 10 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(13 thanks from 8 posts)
looks_5Maybe a little bit different journalby Malykubo
(7 thanks from 5 posts)
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
73 thanks
Would You Sell Your System?
71 thanks
futures io site changelog and issues/problem reporting
30 thanks
Big Mike in Ecuador
26 thanks
The New Micro Contract - MICRO BITCOIN coming May 2021
22 thanks
(login for full post details)
  #3 (permalink)
Birmingham UK
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
ratfink's Avatar
Posts: 3,651 since Dec 2012
Thanks: 17,422 given, 8,403 received

BadWood17 View Post
But something isn`t working.

Check that the ATI interface is enabled as well:

Travel Well
Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to ratfink for this post:

futures io Trading Community Platforms and Indicators NinjaTrader > С++ API using NtDirect.dll doesn`t work

Last Updated on June 18, 2018

Upcoming Webinars and Events

NinjaTrader Indicator Challenge!


Journal Challenge w/$1,800 in prizes!


Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only

Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts