Here the Steps I follow
1) Enable AT interface through NT8/Options/Automated Trading Interface/AT Interface
2) Create custom stock symbol "TEST" and fill the External property under the Symbol Map section
3) Connect to the external connection
4) Open a chart for my TEST symbol. The chart is empty and on the top left corner there is a "Loading..." text
5) Create a simple console application where I use
class Program {
[DllImport("NTDirect.dll")]
public static extern int Last(string instrument, double price, int size);
[STAThread]
static void Main(string[] args) {
// var client = new NinjaTrader.Client.Client();
// client.SetUp("127.0.0.1", 36973);
// var connected = client.Connected(900);
Random rDelta = new Random();
// prices start at 100 and will randomly move and down within the while loop below
double lastPrice = 100.00;
// direction determines the movement, 1 is up, -1 is down. start with up
int direction = 1;
bool go = true;
while (go == true) {
Thread.Sleep(2000);
// generate a random LastPrice;
direction = direction == 1 ? -1 : 1; // if last move was up, this move will be down and vise versa
int delta = rDelta.Next(5);
lastPrice += delta * direction;
System.Console.WriteLine("Direction " + direction + "Delta " + delta + "Last Price " + lastPrice);
// if (client.Last("TEST",lastPrice,100)==-1)
// throw new NotImplementedException();
// call Ninja and set the last price with a volume of 100
if (Last("TEST", lastPrice, 100) == -1) {
System.Console.WriteLine("There was an error calling ninja - terminating execution");
break;
}
}
}
}
I also tested NT7 and works fine

Comment