![]() |
|
|||||||
| Connecting Support for establishing connections to your broker or market data service provider. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
|
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!"; } |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 | |
|
Junior Member
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
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!"; } |
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
|
Ok, so does this code work for you now as expected or not? Do you get 0 returned for the SubscribeMarketData call?
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
|
|
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Likely you should not be opening new data streams every single time your code processes.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
|
I don't understand.
May you give me an example? |
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
|
Hi NinjaTrader_Josh,
Thank you for your attention, but I made the "BVMF3.SA" as an instrument in my NinjaTrader but doesn't work.
|
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Please just try with a standard instrument first. Something like AAPL is easy to test if you have equities data from your data provider.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |