protected override void OnMarketDepth(MarketDepthEventArgs e)
{
for (int i = 0; i < 5; i++)
{
bidvol = MarketDepth.Asks[i].Volume;
askvol = MarketDepth.Bids[i].Volume;
}
balance = bidvol/askvol;
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Accessing MarketDepth Data
Collapse
X
-
Accessing MarketDepth Data
I'm trying to develop an indicator that will pull the marketdepth volume for bid and asks then perform a simple calculation, but I cannot seem to find the right syntax to do it. When i try to compile it I get the following error
This is the code I thought would work:Using the generic type 'NinjaTrader.Data.MarketDepth<T>' requires 1 type arguments
Any help would be great. Thank you.Code:Tags: None
-
Hello maxwellspi,
Thank you for your post.
I'd suggest taking a look at the example from our help guide of building your own Level 2 book:
The incoming event being processed should be checked whether it is an ask or bid event. You can check whether it's an ask or bid event with:
That example linked above shows assigning the values to a list, but you could use a different method to hold the prices if you like.Code:if (e.MarketDataType == MarketDataType.Ask) { //do something } if (e.MarketDataType == MarketDataType.Bid) { //do something }
Please let us know if we may be of further assistance to you.
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
35 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
20 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
12 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
18 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
20 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Comment