unit NinjaTrader;
interface
const
NT_NO_SHOW_DIALOG = 0;
NT_LAST = 0;
NT_BID = 1;
NT_ASK = 2;
NT_SUCCESS = 0;
NT_ERROR = -1;
NT_CONFIRM_ON = 1;
NT_CONFIRM_OFF = 0;
//Sets the ask price and size for the specified instrument. A return value of
//0 indicates success and -1 indicates an error.
FUNCTION Ask(instrument : pAnsiChar; price : double; size : integer) :
integer; stdcall; external 'NtDirect.dll';
//Sets the ask price and size for the specified instrument for use when
//synchronizing NinjaTrader playback with an external application playback.
//A return value of 0 indicates success and -1 indicates an error. The
//timeStamp parameter format is "yyyyMMddhhmmss".
FUNCTION AskPlayback(instrument : pAnsiChar; price : double; size :
integer; timestamp : pAnsiChar) : integer;
stdcall; external 'NtDirect.dll';
//Gets the average entry price for the specified instrument/account
//combination.
FUNCTION AvgEntryPrice(instrument : pAnsiChar; account : pAnsiChar) :
double; stdcall; external 'NtDirect.dll';
//Gets the average entry price for the specified orderId.
FUNCTION AvgFillPrice(orderId : pAnsiChar) : double;
stdcall; external 'NtDirect.dll';
//Sets the bid price and size for the specified instrument. A return value of
//0 indicates success and -1 indicates an error.
FUNCTION Bid(instrument : pAnsiChar; price : double; size : integer) :
integer; stdcall; external 'NtDirect.dll';
//Sets the bid price and size for the specified instrument for use when
//synchronizing NinjaTrader playback with an external application playback.
//A return value of 0 indicates success and -1 indicates an error. The
//timeStamp parameter format is "yyyyMMddhhmmss".
FUNCTION BidPlayback(instrument : pAnsiChar; price : double;
size : integer; timestamp : pAnsiChar) : integer;
stdcall; external 'NtDirect.dll';
//Gets the buying power for the specified account. *Not all brokerage
//technologies support this value.
FUNCTION BuyingPower(account : pAnsiChar) : double;
stdcall; external 'NtDirect.dll';
//Gets the cash value for the specified account. *Not all brokerage //technologies support this value.
FUNCTION CashValue(account : pAnsiChar) : double;
stdcall; external 'NtDirect.dll';
//Function for submitting, cancelling and changing orders, positions and
//strategies. Refer to the Commands and Valid Parameters section for
//detailed information. A return value of 0 indicates success and -1
//indicates an error.The Log tab will list context sensitive error information.
FUNCTION Command(command : pAnsiChar; account : pAnsiChar;
instrument : pAnsiChar; action : pAnsiChar; quantity : integer;
orderType : pAnsiChar; limitPrice : double; stopPrice : double;
timeInForce : pAnsiChar; oco : pAnsiChar; orderId : pAnsiChar;
strategy : pAnsiChar; strategyId : pAnsiChar ) : integer;
stdcall; external 'NtDirect.dll';
//The parameter confirm indicates if an order confirmation message will
//appear. This toggles the global option that can be set manually via
//NinjaTrader Control Center Tools-->Options, "Confirm order placement"
//checkbox. A value of 1 sets this option to true, any other value sets this
//option to false.
FUNCTION ConfirmOrders(confirm : integer) : integer;
stdcall; external 'NtDirect.dll';
//Returns a value of zero if the DLL has established a connection to the
//NinjaTrader server (application) and if the ATI is currently enabled or, -1
//if it is disconnected. Calling any function in the DLL will automatically
//initiate a connection to the server. The parameter showMessage indicates
//if a message box is displayed in case the connection can not be
//established. A value of 1 = show message box, any other value = don't
//show message box.
FUNCTION Connected(showMessage : integer) : integer;
stdcall; external 'NtDirect.dll';
//Gets the number of contracts/shares filled for the orderId.
FUNCTION Filled(orderId : pAnsiChar) : integer;
stdcall; external 'NtDirect.dll';
//Sets the last price and size for the specified instrument. A return value of
//0 indicates success and -1 indicates an error.
FUNCTION Last(instrument : pAnsiChar; price : double; size : integer) :
integer; stdcall; external 'NtDirect.dll';
//Sets the last price and size for the specified instrument for use when
//synchronizing NinjaTrader playback with an external application playback.
//A return value of 0 indicates success and -1 indicates an error. The
//timeStamp parameter format is "yyyyMMddhhmmss".
FUNCTION LastPlayback(instrument : pAnsiChar; price : double;
size : integer; timestamp : pAnsiChar) : integer;
stdcall; external 'NtDirect.dll';
//Gets the most recent price for the specified instrument and data type.
// 0 = last, 1 = bid, 2 = ask.
// You must first call the SubscribeMarketData() function prior
// to calling this function.
FUNCTION MarketData(instrument : pAnsiChar; iType : integer ) : double;
stdcall; external 'NtDirect.dll';
//Gets the market position for an instrument/account combination. Returns
// 0 for flat, negative value for short positive value for long.
FUNCTION MarketPosition(instrument : pAnsiChar; account : pAnsiChar) :
integer; stdcall; external 'NtDirect.dll';
//Gets a new unique order id value.
FUNCTION NewOrderId() : pAnsiChar;
stdcall; external 'NtDirect.dll';
//Gets a string of order ids of all orders of an account separated by '|'. *If
//a user defined order id was not originally provided, the internal token id
//value is used since it is guaranteed to be unique.
FUNCTION Orders(account : pAnsiChar) : pAnsiChar;
stdcall; external 'NtDirect.dll';
//Gets the order state (see definitions) for the orderId. Returns an empty
//string if the order id value provided does not return an order.
FUNCTION OrderStatus ( OrderID: pAnsiChar ) : pAnsiChar;
stdcall; external 'NtDirect.dll';
//Gets the realized profit and loss of an account.
FUNCTION RealizedPnL(account : pAnsiChar) : double;
stdcall; external 'NtDirect.dll';
//Optional function to set the host and port number. By default, host is set
//to "localhost" and port is set to 36973. The default port number can be
//set via the General tab under Options. If you change these default
//values, this function must be called before any other function. A return
//value of 0 indicates success and -1 indicates an error.
FUNCTION SetUp(host : pAnsiChar; port : integer ) : integer;
stdcall; external 'NtDirect.dll';
//Gets a string of order ids of all stop loss orders of an ATM strategy
//separated by '|'. Internal token id value is used since it is guaranteed to
//be unique.
FUNCTION StopOrders(strategyId : pAnsiChar) : pAnsiChar;
stdcall; external 'NtDirect.dll';
//Gets a string of strategy ids of all ATM strategies of an account
//separated by '|'. Duplicate ID values can be returned if strategies were
//initiated outside of the ATI.
FUNCTION Strategies(account : pAnsiChar) : pAnsiChar;
stdcall; external 'NtDirect.dll';
//Gets the position for a strategy. Returns 0 for flat, negative value for
//short and positive value for long.
FUNCTION StrategyPosition(strategyId : pAnsiChar) : integer;
stdcall; external 'NtDirect.dll';
//Starts a market data stream for the specific instrument. Call the
//MarketData() function to retrieve prices. Make sure you call the
//UnSubscribeMarketData() function to close the data stream. A return
//value of 0 indicates success and -1 indicates an error.
FUNCTION SubscribeMarketData(instrument : pAnsiChar) : integer;
stdcall; external 'NtDirect.dll';
//Gets a string of order ids of all profit target orders of an ATM strategy
//separated by '|'. Internal token id value is used since it is guaranteed to
//be unique.
FUNCTION TargetOrders(strategyId : pAnsiChar) : pAnsiChar;
stdcall; external 'NtDirect.dll';
//Disconnects the DLL from the NinjaTrader server. A return value of 0
//indicates success and -1 indicates an error.
FUNCTION TearDown() : integer;
stdcall; external 'NtDirect.dll';
//Stops a market data stream for the specific instrument. A return value of
//0 indicates success and -1 indicates an error.
FUNCTION UnsubscribeMarketData(instrument : pAnsiChar) : integer;
stdcall; external 'NtDirect.dll';
implementation
end.