TS to Ninja Interface Fix

Hi all. I’ve always noticed that my time-and-sales on ninjatrader didn’t match my tradestation time-and-sales when I hooked up the TS datafeed. Now that I’m beta-testing our advanced volume indicators, I need all the data! So, I did a little debugging and changed the NTExternalFeed code that came with ninja. Now, I get a perfect datafeed, as far as I can tell. Finally, my volume charts match, and my volume indicators do the right thing!

So, if you use Ninja with a TS datafeed, I’d open the NTExternalFeed easylanguage script and make it look like this:


{ Copyright (c) 2005, NinjaTrader LLC
  ninjatrader@ninjatrader.com }
[IntrabarOrderGeneration = TRUE]

DefineDLLFunc:  "NtDirect.dll",
  int, "Ask", lpstr, double, int;
DefineDLLFunc:  "NtDirect.dll",
	int, "Bid", lpstr, double, int;
DefineDLLFunc:  "NtDirect.dll",
	int, "Last", lpstr, double, int;
DefineDLLFunc:  "NtDirect.dll",
	int, "SetUp", lpstr, int;

vars: intrabarpersist lastCurrentBar(-1),
		intrabarpersist lastVolume(0),
		vol(0);

if LastBarOnChart then begin
	if lastCurrentBar <> CurrentBar then begin
		vol = ticks;
		lastVolume = 0;
	end else begin
		vol = ticks - lastVolume;
   	end;

	lastCurrentBar = CurrentBar;
	lastVolume = ticks;

  Ask(GetSymbolName, CurrentAsk, AskSize);
  Bid(GetSymbolName, CurrentBid, BidSize);
  Last(GetSymbolName, Close, vol);
end;

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.