public MyAddOnTab()
{
// Subscribe to market data. Snapshot data is provided right on subscription
// Note: "instrument" is a placeholder in this example, you will need to replace
// with a valid Instrument object through various methods or properties available depending
// on the NinjaScript type you are working with (e.g., Bars.Instrument or Instrument.GetInstrument()
marketDepth = new MarketDepth<MarketDepthRow>(instrument);
marketDepth.Update += OnMarketDepth;
}
// This method is fired on market depth events and after the snapshot data is updated.
private void OnMarketDepth(object sender, MarketDepthEventArgs e)
{
// Print the Ask's price ladder
for (int i = 0; i < marketDepth.Asks.Count; i++)
{
NinjaTrader.Code.Output.Process(string.Format("Position: {0} Price: {1} Volume: {2}", i,
marketDepth.Asks[i].Price, marketDepth.Asks[i].Volume), PrintTo.OutputTab1);
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Exposed marketDepth Data Ask/Bid Arrays
Collapse
X
-
Exposed marketDepth Data Ask/Bid Arrays
I am wondering how to access the marketdata arrays much like in this AddOn example within and Indicator/Strategy that uses the OnMarketDepth() function:
Code:Tags: None
-
Hello NJA_MC,
Thank you for writing in. I will confirm whether this is or should be possible inside an indicator/strategy and if so what method would be preferred for accomplishing this. Please note: Our normal operating hours are between 8:30AM EST and 6:00PM EST Monday through Friday.
Thank you for your patience in the meantime.Michael M.NinjaTrader Quality Assurance
-
Hello NJA_MC,
You will be able to utilize that code in an indicator/strategy just as you do in an AddOn.
You'll want to place
in State == State.DefaultsCode:marketDepth = new MarketDepth<MarketDepthRow>(instrument); marketDepth.Update += OnMarketDepth;
Be aware, however, that this will not work with Market Replay; it will only work with live data.
Please, let us know if we may be of further assistance.Zachary G.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
24 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
25 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|
||
|
Started by CaptainJack, 03-25-2026, 09:53 PM
|
0 responses
30 views
0 likes
|
Last Post
by CaptainJack
03-25-2026, 09:53 PM
|
||
|
Started by CaptainJack, 03-25-2026, 09:51 PM
|
0 responses
18 views
0 likes
|
Last Post
by CaptainJack
03-25-2026, 09:51 PM
|
||
|
Started by Mindset, 03-23-2026, 11:13 AM
|
0 responses
27 views
0 likes
|
Last Post
by Mindset
03-23-2026, 11:13 AM
|

Comment