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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            591 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            342 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            555 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X