NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Connecting

Connecting Support for establishing connections to your broker or market data service provider.

Reply
 
Thread Tools Display Modes
Old 08-13-2009, 09:03 PM   #1
MiThEuS
Junior Member
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default C#.NET <-> NinjaTrader

Hi,

I made this code, but doesn't work. My return always is 0.

Client c = new Client();
if (c.Connected(1).Equals(0))
{
c.SubscribeMarketData("BVMF3.SA");
double value = c.RealizedPnL("BVMF3.SA");
textBox1.Text = value.ToString();
}
else
{
textBox1.Text = "Error!";
}
MiThEuS is offline  
Reply With Quote
Old 08-14-2009, 05:22 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Welcome to our forums, I suggest you check into the sample code provided in the C:\Program Files\NinjaTrader 6.5\bin\AutoTrade folder > NinjaTraderCSharpSampleApplication.zip

For the RealizedPnL call, it works for the account where you pass a symbol in - http://www.ninjatrader-support.com/H...ientClass.html
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 08-14-2009, 06:32 AM   #3
MiThEuS
Junior Member
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Welcome to our forums, I suggest you check into the sample code provided in the C:\Program Files\NinjaTrader 6.5\bin\AutoTrade folder > NinjaTraderCSharpSampleApplication.zip

For the RealizedPnL call, it works for the account where you pass a symbol in - http://www.ninjatrader-support.com/H...ientClass.html

Hi,

The correct code is this:

Client c = new Client();
if (c.Connected(1).Equals(0))
{
c.SubscribeMarketData("BVMF3.SA");
double value = c.MarketData("BVMF3.SA", 2);
textBox1.Text = value.ToString();
}
else
{
textBox1.Text = "Error!";
}
MiThEuS is offline  
Reply With Quote
Old 08-14-2009, 06:39 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Ok, so does this code work for you now as expected or not? Do you get 0 returned for the SubscribeMarketData call?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 08-14-2009, 07:34 AM   #5
MiThEuS
Junior Member
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Ok, so does this code work for you now as expected or not? Do you get 0 returned for the SubscribeMarketData call?
I get 0, but I expected 12,50 as is showed in NinjaTrader for this instrument.
MiThEuS is offline  
Reply With Quote
Old 08-14-2009, 07:43 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Likely you should not be opening new data streams every single time your code processes.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-14-2009, 11:29 AM   #7
MiThEuS
Junior Member
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

I don't understand.

May you give me an example?
MiThEuS is offline  
Reply With Quote
Old 08-14-2009, 11:46 AM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

if (c.Connected(1).Equals(0))
{
c.SubscribeMarketData("BVMF3.SA");
double value = c.MarketData("BVMF3.SA", 2);
textBox1.Text = value.ToString();

You are subscribing every single time possible. You don't need to keep subscribing. Once you have subscribed that is it. Also, BVMF3.SA actually needs to be an instrument in NinjaTrader.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-14-2009, 11:55 AM   #9
MiThEuS
Junior Member
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi NinjaTrader_Josh,

Thank you for your attention, but I made the "BVMF3.SA" as an instrument in my NinjaTrader but doesn't work.

MiThEuS is offline  
Reply With Quote
Old 08-14-2009, 11:59 AM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Please just try with a standard instrument first. Something like AAPL is easy to test if you have equities data from your data provider.
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
InteractiveBrokers>OwnData>TS8>NinjaTrader(Simulation Edition)<Interactive Brokers virtu Automated Trading 28 05-26-2010 03:35 PM
List<PriceRows> pRows = new List<PriceRows>(); funk101 General Programming 2 10-05-2008 03:18 AM
Reliability 6.5 beta <-->6 joker Historical NinjaTrader 6.5 Beta Threads 1 01-28-2008 05:35 AM
A <> B what is this mean? stevebong General Programming 2 11-29-2007 10:59 PM
"The namespace Ninjatrader.Indicator already contains a definition for '<indicator>'" eeisen Strategy Development 3 09-02-2007 09:47 PM


All times are GMT -6. The time now is 09:21 PM.