Console app for Ninja ATI - NinjaTrader Programming | futures io social day trading
futures io futures trading


Console app for Ninja ATI
Updated: Views / Replies:5,058 / 12
Created: by MXASJ Attachments:3

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 3  
 
Thread Tools Search this Thread
 

Console app for Ninja ATI

  #1 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

Console app for Ninja ATI

I wrote this small console application in C# to help a guy in another forum, but thought some users here might find it interesting. It is pretty basic and just gets the last price on ES 12-10 before shutting down. It uses the ATI interface to Ninja.

You can compile it as an exe or run it in your IDE's debug mode to check it out.

If you are really bored you can turn it into a WinForms or WPF app and post it back .

 
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using NinjaTrader.Client;
namespace NTConnectTest
{
classProgram
{
staticvoid Main(string[] args)
{
string inst = "ES 12-10";
string input1;
string input2;
double last = 0;
int connStatus;
bool getData = false;
int myCounter = 0;
 
NinjaTrader.Client.Client NTClient = new NinjaTrader.Client.Client();
Console.WriteLine("Connect to Ninja Trader? y/n");
input1 = Console.ReadLine();
switch (input1)
{
case"y":
getData = true;
NTClient.SubscribeMarketData(inst);
break;
case"n":
getData = false;
Console.WriteLine("Ok. Bye. Press <ENTER> to terminate program...", input1);
input2 = Console.ReadLine();
break;
 
default:
getData = false;
Console.WriteLine("ERROR: Your input {0} is incorrect. Press <ENTER> to terminate program...", input1);
input2 = Console.ReadLine();
break;
}
connStatus = NTClient.Connected(0);
if (connStatus == 0 && getData == true) Console.WriteLine("Connected to NinjaTrader");
elseif (connStatus != 0 && getData == true)
{
getData = false;
Console.WriteLine("ERROR: Can not connect. Press <ENTER> to terminate program...", input1);
input2 = Console.ReadLine();
}
 
if (getData)
{
 
last = NTClient.MarketData(inst, 0);
Console.WriteLine(inst + " Last Price: " + last);
Console.Write("Logging off in 10 secs");
while (myCounter <= 10)
{
Thread.Sleep(500);
Console.Write(".");
myCounter++;
}
NTClient.UnsubscribeMarketData(inst);
NTClient.TearDown();
}
if (!getData)
{
NTClient.UnsubscribeMarketData(inst);
NTClient.TearDown();
}
 
 
 
 
}
}
}

Reply With Quote
The following 7 users say Thank You to MXASJ for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received


Brilliant, I hadn't considered such an approach before for getting information out of NinjaTrader, only pushing information to...



Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #4 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

Thanks for the kind words, Mike.

Its a holiday here and I was bored so I actually did write a extremely basic WinForms app called APITrader that buys and sells ES 12-10 and shows the bid/ask/last/market position. If anyone is interested holla back and and I'll post it as a VS 2010 Project file.

It is coded by a complete neophyte (me) but I'm under pressure to get up to speed on this kind of thing quickly, so welcome to WinForms 101 for Ninja .

Attached Thumbnails
Console app for Ninja ATI-apitrader.jpg  
Reply With Quote
The following 5 users say Thank You to MXASJ for this post:
 
  #5 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

Last post for me tonight. By Monday this might be interesting...

Attached Thumbnails
Console app for Ninja ATI-lastfriday.jpg  
Reply With Quote
The following 4 users say Thank You to MXASJ for this post:
 
  #6 (permalink)
Elite Member
duluth,mn
 
Futures Experience: Advanced
Platform: ninja,thinkorswim
Broker/Data: Amp-Zenfire
Favorite Futures: ES,Options
 
Posts: 648 since Feb 2010
Thanks: 81 given, 1,349 received

I would sure like to play with it if your willing to share. I am thinking of heading in this direction for some other ideas and this reading of your code might really give me a jumpstart

Thanks

Tim

Reply With Quote
 
  #7 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received


timmyb View Post
I would sure like to play with it if your willing to share. I am thinking of heading in this direction for some other ideas and this reading of your code might really give me a jumpstart

Thanks

Tim

Sure. Do you have VS2010? I can attached zipped project files. If not I can attach the main code files.

Note the Ninja ATI is pretty limited in what it can do. But it's a great place to start.

EDIT: Attached the VS2010 Project for the APITrader thing I posted November 5th. I haven't played with it since (other things to do), and it is set up only to buy/sell ES 12-10, but the code might be a starting point for something.

Attached Files
Register to download File Type: zip APITrader.zip (261.1 KB, 151 views)

Last edited by MXASJ; December 12th, 2010 at 07:48 AM.
Reply With Quote
The following 4 users say Thank You to MXASJ for this post:
 
  #8 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

If you are OK with console apps this is something I played with more recently to add other examples and play with stuff:

 
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using NinjaTrader.Client;
namespace NTConnectTest
{
classProgram
{
staticvoid Main(string[] args)
{
string inst = "ES 12-10";
string input1;
string input2;
double last;
double bid;
double ask;
int connStatus;
bool getData = false;
int myCounter = 0;

NinjaTrader.Client.Client NTClient = new NinjaTrader.Client.Client();
Console.WindowWidth = 100;
Console.Title = "NT Connect Test";

Console.WriteLine("Connect to Ninja Trader? y/n");
input1 = Console.ReadLine();
switch (input1)
{
case"y":
getData = true;
NTClient.SubscribeMarketData(inst);
break;
case"n":
getData = false;
Console.WriteLine("Ok. Bye. Press <ENTER> to terminate program...", input1);
input2 = Console.ReadLine();
break;

default:
getData = false;
Console.WriteLine("ERROR: Your input {0} is incorrect. Press <ENTER> to terminate program...", input1);
input2 = Console.ReadLine();
break;
}
connStatus = NTClient.Connected(0);
if (connStatus == 0 && getData == true)
{
Console.WriteLine("Connected to NinjaTrader");
Console.WriteLine("");
}
elseif (connStatus != 0 && getData == true)
{
getData = false;
Console.WriteLine("ERROR: Can not connect. Press <ENTER> to terminate program...", input1);
input2 = Console.ReadLine();
}

if (getData)
{
//if (connStatus == 0) Console.WriteLine("Connected to NinjaTrader");
last = NTClient.MarketData(inst, 0);
bid = NTClient.MarketData(inst, 1);
ask = NTClient.MarketData(inst, 2);
string orders = NTClient.Orders("Sim101");
double pnl = NTClient.RealizedPnL("Sim101");

Console.WriteLine("Return of NTClient.MarketData:");
Console.WriteLine(DateTime.Now + " " + inst + " Last Price: " + last + " Bid/Ask: " + bid+"/"+ask);
Console.WriteLine("");
Console.WriteLine("Return of NTClient.Orders:");
Console.WriteLine(orders);
Console.WriteLine("");
Console.WriteLine("Return of NTClient.RealizedPnL:");
Console.WriteLine(Math.Round(pnl,2));
Console.Write("Logging off in 10 secs");
while (myCounter <= 10)
{
Thread.Sleep(500);
Console.Write(".");
myCounter++;
}
NTClient.UnsubscribeMarketData(inst);
NTClient.TearDown();
}
if (!getData)
{
NTClient.UnsubscribeMarketData(inst);
NTClient.TearDown();
}
 
 
 
 
}
}
}

Reply With Quote
The following 6 users say Thank You to MXASJ for this post:
 
  #9 (permalink)
Elite Member
duluth,mn
 
Futures Experience: Advanced
Platform: ninja,thinkorswim
Broker/Data: Amp-Zenfire
Favorite Futures: ES,Options
 
Posts: 648 since Feb 2010
Thanks: 81 given, 1,349 received


MXASJ View Post
Sure. Do you have VS2010? I can attached zipped project files. If not I can attach the main code files.

Note the Ninja ATI is pretty limited in what it can do. But it's a great place to start.

EDIT: Attached the VS2010 Project for the APITrader thing I posted November 5th. I haven't played with it since (other things to do), and it is set up only to buy/sell ES 12-10, but the code might be a starting point for something.

thanks I will look at it, I have visual studio 2008 pro. I am thinking the files should work fine. Thanks again for sharing

Reply With Quote
 
  #10 (permalink)
Trading Apprentice
New York USA
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: Oil
 
Posts: 1 since May 2011
Thanks: 0 given, 0 received


Thanks for the APITrader code.

I downloaded APITrader and I am using NinjaTrader 7.0.1000.4

I have VS2010 and when I run APITrader it does not connect to NinjaTrader - I have NinjaTrader running along with the Simulated Data Feed.
The bottom left is in red and it indicates the connection to NinjaTrader is not active. I have also tried the file menu connect option and it does not work.

Any ideas?

Reply With Quote

Reply



futures io > > > > > Console app for Ninja ATI

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
jtEconNews Reader is here as a stand alone app MetalTrade NinjaTrader 11 November 15th, 2013 12:42 AM
iPhone and Android app for the forum GentleTrader Traders Hideout 50 March 26th, 2012 12:46 AM
Switching Fin.Alg TPO Market profile from Ninja 6.5 to ninja 7 MadManmos Trading Reviews and Vendors 19 August 23rd, 2011 09:15 AM
APP: The Forex Game babypowder Off-Topic 0 August 4th, 2011 10:53 AM


All times are GMT -4. The time now is 08:28 AM.

Copyright © 2017 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
Page generated 2017-12-15 in 0.21 seconds with 20 queries on phoenix via your IP 54.234.247.118