View Full Version : Where is bid/ask size?
Profitmake
05-07-2010, 12:10 AM
Ninjatrader v6 and 7
I can't see anything in Market Analyzer which I can add "bid/ask size". This is one of the most basic information. Why isn't it available?
I would like to like to set alerts on bid/ask size, their relative sizes etc.
NinjaTrader_Bertrand
05-07-2010, 04:07 AM
Profitmake, for this you would need to create an indicator in our NinjaScript accessing OnMarketData's Level 1 info.
http://www.ninjatrader-support.com/HelpGuideV6/OnMarketData.html
Profitmake
05-09-2010, 04:20 AM
Thanks for your reply. But I couldn't figure out how to do it. An indicator couldn't be added into MArket Analyzer. Also I can't find a way to set an alert on the indicator either.
1. Could you please provide the code to display bid/ask size on Market Analyzer?
I just need two scripts, one displaying the bid size, another ask size.
2. This is one of the most basic information that you could see in stock quotation. I hope it can be readily available. Please consider to add it in the next build.
NinjaTrader_Ben
05-09-2010, 11:30 AM
Hello,
1- If I understand what you want, just plot the GetCurrentBidVolume() in an indicator then attach that indicator to the MA just like you would any other indicator. I am sorry we don't develop for customers. We can give tips though.
2- Have you looked at the time and sales and Level II windows?:
http://www.ninjatrader-support.com/HelpGuideV6/Overview19.html
http://www.ninjatrader-support.com/HelpGuideV6/Overview43.html
Both can be found under File>New.
Profitmake
05-09-2010, 02:31 PM
Hello,
1- If I understand what you want, just plot the GetCurrentBidVolume() in an indicator then attach that indicator to the MA just like you would any other indicator. I am sorry we don't develop for customers. We can give tips though.
2- Have you looked at the time and sales and Level II windows?:
http://www.ninjatrader-support.com/HelpGuideV6/Overview19.html
http://www.ninjatrader-support.com/HelpGuideV6/Overview43.html
Both can be found under File>New.
Well this is actually what I want.
http://www.ninjatrader.com/support/forum/attachment.php?attachmentid=11385&stc=1&d=1273436949
Market Analyzer serves a different purpose than T&S/Level II. I can monitor plenty of stock quotes at a glance in Market Analyzer. If I were to use either of them I would have to open tons of windows which would become a mess.
The very basic of a stock quote:
1. Instrument name
2. Current (last) price and last size
3. Change
4. Volume
5. Open / High / Low / Close
6. Bid price and bid size
7. Ask price and ask size
You have most of them but you missed three which are the fundamentals of a stock quote. Level 1 (top market quote) is the most basic one. Many daytraders and swing traders need it. How could I monitor the stock with incomplete Level I data?
Besides Market Analyzer let me set alert, cell and filter conditions while T&S / Level II don't. I would like to set alerts on bid/ask size. I couldn't do it in T&S / Level II.
That's why I strongly suggest your team to add the two most basic information into Market Analyzer. I guess this is a small request which should take little effort to implement. Please seriously consider it.
Profitmake
05-09-2010, 02:45 PM
I think I really suck. I tried so many times in vain. I'm not really coding/programming. is not even an indicator at all literally speaking.
I merely want to see bid size and ask size. That's it!
So I just want one so-called indicator to display bid size, another to display ask size.
I tried to create a ninjascript just to show bid/ask size in Market Analyzer. This was all I have tried. I have followed your tips and suggestions. But none of it worked. I can't add the custom "indicator" because it doesn't show up in any list, be it in "Chart > Indicators", or in "Market Analyzer > Columns... > Indicators".
(Problem solved. See reply below)
NinjaTrader_Ben
05-09-2010, 07:52 PM
Hello,
I am sorry, we can't code it for you.
Try using this in the OnBarUpdate section:
Value.Set(GetCurrentBidVolume());
Try it and see. I'm not sure if it will work.
Profitmake
05-09-2010, 08:51 PM
Thanks for the pointer.
I found out Market Analyzer misses last size (last traded size) too. But
Value.Set(GetCurrentLastVolume()); doesn't exist.
After all bid/ask/last size should be added to Market Analyzer for the benefits of all customers. :)
NinjaTrader_Bertrand
05-10-2010, 04:06 AM
Profitmake, I believe Ben referred to something like the attached, plotting the current bid volume in realtime, you can easily add to the MA as colums, vice versa doable for the ask volume with this starting point.
Profitmake
05-10-2010, 06:48 AM
Hello thank you so much for the file. Do you know what command I should use instead if I want to show last size.
The bid and ask size are both completed. Thank you for both of your help. Only last size is left out now.
NinjaTrader_Bertrand
05-10-2010, 06:59 AM
You would either need to grab it from OnMarketData's Level 1 info, or use VOL with CalculateOnBarClose set to false.
Profitmake
05-12-2010, 02:41 PM
Thank you for your suggestion. Your "VOL" approach works well.
I have tested the given indicators a few times recently. I tried to plot bid size and ask size (record once per minute) on the chart. However they don't seem to work reliably. The value goes wrong in some time. Also the bar fails to update most of the time even if "CalculateOnBarClose" is set to false.
I suspect the problem lies on this two functions GetCurrentBidVolume() and GetCurrentAskVolume(). Would it be a bug on your platform or just my mistake? Could you check to see if you encounter the same problem on your end?
NinjaTrader_RyanM
05-12-2010, 03:12 PM
Hello Profitmake,
Could you clarify what you mean by "goes wrong in sometime"?
If you share the setup you're using we can test on our side. Please include details such as Instrument/ provider/ chart interval, and the exact code you're using. Neither file you posted contains anything that divides GetCurrentBidVolume() / GetCurrentAskVolume()
Profitmake
05-12-2010, 10:44 PM
Sorry that I'm not clear enough last time.
Well I actually want to say I suspect the problem lies on the two functions, which are GetCurrentBidVolume() and GetCurrentAskVolume().
Today I investigated further and I found that it appears the current bid/ask size only updates when a trade executed, not when the current bid/ask size changes.
VOL shares the same problem. I use VOL indicator as a workaround (suggested by your staff) to get last size but it doesn't update immediately when you add it.
http://www.ninjatrader.com/support/forum/attachment.php?attachmentid=11487&stc=1&d=1273725221
(Hong Kong stock: 8159, HKEX)
As you see:
Bid size is the same as bid price.
Ask size is the same as ask price.
VOL shows nothing even though last size is available.
The problem doesn't go away until the next few trades done which may make the system to update the bid/ask/last size.
Similar problems arise when you plot the bid/ask size indicators into the chart. Try it yourself:
1. Find a stock which is moderately traded so it's easier for you to spot the discrepancies.
2. Open 1 minute chart
3. Watch closely the value shown on the chart and IB booktrader (in case you use IB).
4. The bid/ask size isn't right at times.
Profitmake
05-12-2010, 10:46 PM
By the way I wonder if Ninjatrader can plot historical bid/ask size from IB datafeed. Currently it only works real time. I think I can remove that portion of code:
if (Historical)
return;
But is it able to get the right historical values?
I believe this code tells the system that if it's historical data, simply plots nothing and return to the first part of the command.
NinjaTrader_Bertrand
05-13-2010, 07:07 AM
Profitmake, your outcomes are expected as you work in the OnBarUpdate() that would trigger updates on each tick if CalculateOnBarClose is set to false.
For updates on each Level 1 data change, you would need to work in the OnMarketData() method as suggested.
Historical bid / ask data series access is supported for IB in our NinjaTrader 7 release, which is currently in public beta.
Profitmake
05-14-2010, 05:12 AM
I'm up against a brick wall again. I tried to modified it from "OnBarUpdate()" into "OnMarketData()". It didn't work. Here's the modified code:
protected override void OnMarketData(MarketDataEventArgs e)
{
if (Historical)
return;
BidSize0.Set(GetCurrentBidVolume());
}
I tried some other variations too to no avail.
Sorry Bertrand, may I ask you to help me once more?
I merely need some coding advice this time and for this particular issue only. I deadly want the ability to watch bid/ask/last size in Market Analyzer.
Historical bid / ask data series access is supported for IB in our NinjaTrader 7 release, which is currently in public beta.
How can I access those data? Removing this bit of code doesn't seem to work:
if (Historical)
return;
NinjaTrader_Bertrand
05-14-2010, 07:46 AM
For historical bid / ask data series access, please add the respective MarketDataType in the Initialize of the indicator in NT7 -
Add("ES 06-10", PeriodType.Minute, 1, MarketDataType.Ask);
Then you can access the data via pointing to this BarsArray[1] or using Closes[1][0]
http://www.ninjatrader.com/support/helpGuides/nt7/closes.htm
For a correct way to work in OnMarketData(), please see the snippet we have in the helpguide for this method -
http://www.ninjatrader.com/support/helpGuides/nt7/onmarketdata.htm
Profitmake
05-14-2010, 09:12 AM
Add("ES 06-10", PeriodType.Minute, 1, MarketDataType.Ask);
But this code is hardcoded to load the ask size of ES 06-10. I want to load whatever instrument it's currently in. This has to be a variable.
For a correct way to work in OnMarketData(), please see the snippet we have in the helpguide for this method -
http://www.ninjatrader.com/support/h...marketdata.htm (http://www.ninjatrader.com/support/forum/../helpGuides/nt7/onmarketdata.htm)
I have read this more than ten times in a few days. However I have nearly zero programming knowledge so many don't make sense to me at all. I simply kept "brute-forcing" to see if the code works "magically".
I even tried the example and it still failed:
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);
}
Error message:
"NinjaTrader.Indicator.BidSize' does not implement inherited abstract member 'NinjaTrader.Indicator.IndicatorBase.OnBarUpdate() '"
I don't understand what this message means. It appears I'm forced to use OnBarUpdate(). Other codes just don't pass the compile test.
I tried over 1 hour in vain. If it's just a few lines of codes to achieve this, I hope anyone could kindly give me a better pointer so I can watch up-to-date bid/ask/last size in Market Analyzer. Thank you in advance.
I'm still trying in the meantime.
NinjaTrader_Bertrand
05-14-2010, 10:39 AM
Profitmake, you could make the instrument input for this a string user input so you could enter a symbol to be used.
Were you trying to use the OnMarketData() snippet outside the OnBarUpdate() method? This would be needed, as it will not work inside the OnBarUpdate() as it's an own method in NinjaScript.
Since you're not a programmer, it might be best to pass this work to a consultant to create the needed code for you -
http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm
Profitmake
05-14-2010, 12:57 PM
Well my purpose hasn't been changed from day 1. I just want to display bid size, ask size, last size. Unfortunately those information aren't readily available in the columns :(. That's why I'm trying very hard now.
I simply try to hack based on the file you gave it to me last time. Originally I should be all happy. Unfortunately your sample used OnBarUpdate() method, not OnMarketData() method.
I pointed out the problems and you suggested OnMarketData() method. Unfotunately I'm up against a brick wall now since I'm unable to hack your sample to use OnMarketData() method instead.
My first attempt
I have replaced OnBarUpdate() with OnMarketData() so I don't understand what the error message says.
http://www.ninjatrader.com/support/forum/attachment.php?attachmentid=11525&stc=1&d=1273862456
I tried quite many different variations to see if I can guess the right line of the code. I have spent about 30 minutes on that in vain.
Second attempt
I simply copied the example to see how it works. But I couldn't pass the compile test.
http://www.ninjatrader.com/support/forum/attachment.php?attachmentid=11526&stc=1&d=1273862860
I'm searching for simple samples which use OnMarketData() method so I can grab one and try to mock it. So far I couldn't find one.
I tried other variations too. All failed. I must have made some very dummy mistakes. I don't think it's worth wasting space to post screenshots here.
Profitmake
05-14-2010, 12:57 PM
Regarding consultant, it would be silly to ask a consultant for such a simple task that may only take a minute to code. The consultant may laugh out load at me for such a dumb task. I'd better ask people or members on the forum to help this time.
I hope you could help me on this issue if it only takes a few lines of codes to complete it. Otherwise let's just forget it as it's not a reasonable request. I'm still evaluating this software and see whether it fits my trading needs. I will definitely need a consultant to code my system later if I decide this is the right software which I should work on it.
PS: I clicked on the button for info of CS0534 butthe help program failed to redirect me to the right page.
NinjaTrader_Josh
05-14-2010, 01:13 PM
Profitmake,
BidSize is likely a reserved word. You will need to name your indicator differently.
Profitmake
05-14-2010, 04:30 PM
Hello Josh, I created another indicator called ShowBidVol. The same error message occurred when I used OnMarketData() in the code. I still keep trying in the meantime.
NinjaTrader_RyanM
05-14-2010, 05:01 PM
ProfitMake,
You will get error messages from all indicators when you compile, not just the one you're working with.
The bulk of the code you have is the same from this page http://www.ninjatrader-support.com/HelpGuideV6/OnMarketData.html
This code compiles successfully.
You're trying to Set a DataSeries within OnMarketData and this won't work. Data Series are synced to bar objects so you will have to do this within OnBarUpdate()
In the future when sharing code you're using, can you copy and paste the text rather than images?
Profitmake
05-17-2010, 01:38 AM
The bulk of the code you have is the same from this page http://www.ninjatrader-support.com/HelpGuideV6/OnMarketData.html
This code compiles successfully.
Yes I used the sample code just to make sure that pat of code must be error free. Then I tried to fit this bit of code into the file given on this thread but it didn't work.
I know it's a bad way to spot the problem area. Anyway this part is not important.
You're trying to Set a DataSeries within OnMarketData and this won't work. Data Series are synced to bar objects so you will have to do this within OnBarUpdate()
I have tried it for two days before I asked again.
Could you tell me what code exactly I should use to replace DataSeries?
Or perhaps you have a sample OnMarketData() with /
bis/ask so I can try to imitate it?
In the future when sharing code you're using, can you copy and paste the text rather than images?
Yes if you prefer it. But the code would be very long since it will always expand every potion of codes.
NinjaTrader_Bertrand
05-17-2010, 07:13 AM
Profitmake, please attach the latest version of you're cs file directly so we can take a look at what you attempt doing. You can find the file in the Documents\NinjaTrader 6.5\bin\Custom\Indicator folder. If you just work very close alongside the sample from the helpguide you should be able to compile and see the prints for last, bid, ask from the OnMarketData() method accessing the Level 1 stream directly.
Profitmake
05-18-2010, 02:41 AM
Here you are.
Nothing interesting have been done on the indicators. No change I made could pass the compile test so I simply revert to the last state. You may simply create a new sample to replace the mess.
The indicators are simply based on the sample you gave me last time. My purpose is to plot bid/ask size and update properly in real-time.
NinjaTrader_RyanM
05-18-2010, 09:06 AM
Hello Profitmake,
Was using a prior version of your code and it plotted successfully.
The current one has the same issue where values are set within OnMarketData().
You may need to pursuse this with a 3rd party NinjaScript consultant (http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm) who can develop your code to your exact specifications.
jojab
04-06-2012, 11:07 AM
I was looking to do the same and wrote two simple bid size and ask size indicators for the purpose of calling them up within the Market Analyzer. I posted them to the Ninja Version 7 Indicator section of the forum. It is called "Bid and Ask Sizes".