View Full Version : SampleMarketDepth example
MXASJ
03-29-2010, 06:26 AM
Has there changes in the way one would access Level II data as outlined in the SampleMarketDepth indicator posted in the Reference Samples section?
I'm having some problems using <LadderRow> now (I had it working a few betas ago IIRC) and wanted to check before I go too far down that path.
My specific requirement is to find a Bid and Ask depth level where a specific volume exists.
Thanks!
NinjaTrader_Josh
03-29-2010, 08:46 AM
MXASJ,
There would need to be minor changes like using long for the volumes instead of int and using the expanded TriggerCustomEvent() signature with three parameters instead of two.
MXASJ
03-29-2010, 09:10 AM
Thanks Josh,
I might be looking at the wrong tool for the job in terms of code. This is working for me:
protected override void OnMarketDepth(MarketDepthEventArgs e)///////////////////////////////////////////////////////
{
if (BarsInProgress == 0) // The Quoted instrument
{
if (e.MarketDataType == MarketDataType.Bid && e.Position == 0 && e.Operation == Operation.Update)
{
if (printDepth) Print("STRATEGY NinjaSpreader "+ Instrument.FullName+" Best BID is " + e.Price + "\tVOL " + e.Volume);
}
}
else if (BarsInProgress == 1) //The Hedge instrument
{
if (e.MarketDataType == MarketDataType.Ask && e.Position == 0 && e.Operation == Operation.Update)
{
if (printDepth) Print("STRATEGY NinjaSpreader "+ Instrument.FullName+" Best ASK is " + e.Price + "\tVOL " + e.Volume);
}
}
}
And the only thing I need to do now is find the Best Bid/Best Ask WHERE Volume is greater than, say, 10, which is the price I want to know for other calculations. Is there a simple way to do this that you can suggest... or do I need to look at each level until e.Volume >= 10?
NinjaTrader_Josh
03-29-2010, 09:54 AM
I believe you will need to go through and check each row for your condition to determine which one satisfies it the best.
MXASJ
03-30-2010, 03:17 AM
Going back to the SampleMarketDepth code, if I create a new Strategy, add using System.Collections.Generic like this:
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
using System.Collections.Generic;
#endregion
Then add in Variables:
private List<LadderRow> askRows = new List<LadderRow>();
private List<LadderRow> bidRows = new List<LadderRow>();
I get the following error:
The type or namespace name 'LadderRow' could not be found...
Any ideas on what I'm missing? Thanks!
NinjaTrader_Josh
03-30-2010, 08:34 AM
MXASJ,
LadderRow is a custom class made in the sample. Please make sure you have it in your code as well.