Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SampleMarketDepth example

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SampleMarketDepth example

    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!

    #2
    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.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh,

      I might be looking at the wrong tool for the job in terms of code. This is working for me:

      PHP Code:
      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?

      Comment


        #4
        I believe you will need to go through and check each row for your condition to determine which one satisfies it the best.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Going back to the SampleMarketDepth code, if I create a new Strategy, add using System.Collections.Generic like this:

          PHP Code:
          #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:

          PHP Code:
          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!

          Comment


            #6
            MXASJ,

            LadderRow is a custom class made in the sample. Please make sure you have it in your code as well.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            78 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            40 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            63 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            63 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X