![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Feb 2010
Posts: 128
Thanks: 0
Thanked 0 times in 0 posts
|
Hi!
It's strange cause when I open a chart with ZN and ZB instruments I can see the right price displayed on the right right axis, but when I develop an indicator trying to obtain the close, bid or ask data from these instruments it's different that one displayed for each instrument. I've put some displays and i get wrong values, all variables were defined as double: Close[0]: 120,3125 Inputs[0][0]: 120,3125 Inputs[1][0]: 120,171875 Bid(0): 120,3125 Ask(1): 120,1875 Please, see the attached chart, at bottom there's the values of the spread indicator, with last, bid and ask prices of the spread, with other instruments like YC and YW the values shown by the indicator are right. Which could be the problem? Thank you |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hello JoanNT,
There are a couple items here that may explain what you are seeing. GetCurrentAsk() and GetCurrentBid() are real time values. When called historically they will use close prices rather than historical bid / ask. To get the most accuracy for bid/ ask data, you must work in OnMarketData() method. If you are accessing from OBU, it is only updated when there has been a trade. This can be less frequent than changes in level I data, like OnMarketData is used for. Viewing changes in bid / ask data aligned with a bar through charting is challenging because of this. You're comparing two different thing as bid / ask can be updated much more often than trades.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Feb 2010
Posts: 128
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks RyanM
but I'm working with real data and not historical one, I've just copied the example method protected override void OnMarketData(MarketDataEventArgs e) { // Print some data to the Output window if (e.MarketDataType == MarketDataType.Last) Print("Last = " + e.Price + " " + e.Volume); else if (e.MarketDataType == MarketDataType.Ask) Print("Ask = " + e.Price + " " + e.Volume); else if (e.MarketDataType == MarketDataType.Bid) Print("Bid = " + e.Price + " " + e.Volume); } and I got this results: Bid = 120,40625 918 Ask = 120,421875 629 Last = 120,421875 20 Close[0]: 120,421875 Inputs[0][0]: 120,71875 Inputs[1][0]: 120,421875 Bid(0): 120,71875 Ask(1): 120,421875 both prices for Ask are the same and both are wrong, I've tried the same with other instruments and this don't happens |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
How are you determining they're wrong? Who is your data provider?
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Feb 2010
Posts: 128
Thanks: 0
Thanked 0 times in 0 posts
|
I work with IB, simply looking to their IB ask and bid data, the ones i get from NT are far from ones i get from IB
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
It's working OK here. I'm getting the same values in TWS for ZN.
I would make sure you're looking at the same instrument / exchange within both applications. Are you aware of the different formatting between Ninja's output and TWS? Ninja - Decimal TWS - Tick
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Feb 2010
Posts: 128
Thanks: 0
Thanked 0 times in 0 posts
|
I don't see the same values in your attached image, this could be "the different formatting between Ninja's output and TWS", what do you mean?
is there any thread or document about this? thanks! |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
You'll want to check contract specifications for more info on price formatting.
http://www.cmegroup.com/trading/inte...fications.html Points ($1,000) and halves of 1/32 of a point. For example, 126-16 represents 126 16/32 and 126-165 represents 126 16.5/32. Par is on the basis of 100 points. ZN 120^170 = 120.53125
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Feb 2010
Posts: 128
Thanks: 0
Thanked 0 times in 0 posts
|
Ryan Thank you very much, I didn't know about that.
Have a nice day |
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
My pleasure, Joan. Glad we were able to get it sorted.
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Question with GetCurrentBid() | BigDog008 | Strategy Development | 12 | 10-07-2010 08:59 PM |
| GetCurrentAsk() returns wrong price | Buthus | Strategy Development | 9 | 11-06-2009 07:33 AM |
| Premarket GetCurrentBid() GetCurrentAsk() | TheChingachgook | Indicator Development | 5 | 06-18-2009 09:34 AM |
| GetCurrentBid/Ask | SystemTrading | Miscellaneous Support | 1 | 08-20-2008 01:19 PM |
| NT hangs on GetCurrentBid/Ask? | ATI user | Indicator Development | 5 | 10-09-2007 05:19 AM |