Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

e.Operation

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

    e.Operation

    1. Can someone please explain what e.Operation (and .Add, .RemoveAt, .Insert) means and its purpose? I looked at the sample depth strategy, and was wondering why we can't simply say:

    Code:
    for (int i = 0; i < e.MarketDepth.Bid.Count; i++){
          myBidRows[i].Price = e.MarketDepth.Bid[i]  //where myBidRows is a list of LadderRows
    }
    under OnMarketDepth.


    2. Also, I was looking at the sample depth strategy and was wondering where askRows updated. I see rows = askRows and changes made to rows, but I don't see askRows = rows, or for that matter, askRows = [anything] anywhere.

    Thanks!

    #2
    Hello :::grimReaper:::,
    The Operations are performed in terms of price. Say, bid price at position 1 is at 1450. Now if the price remains at 1450 however the volume changes then an Update operation will be done. However if the price changes at position 2 then a Remove operation and a Insert operation will be performed.

    You may further test the following code to understand it
    Code:
    protected override void OnMarketDepth(MarketDepthEventArgs e)
    {
    	if (e.MarketDataType == MarketDataType.Ask)
    	{
    		if (e.Position == 1 && e.Operation != Operation.Update)
    		Print(e.Operation.ToString() + " Price " + e.Price.ToString() + "   " + e.Volume.ToString() + "  Position   " + e.Position.ToString());
    	}
    }
    2. Are you referring to this sample code.


    If so then the below code in the indicator makes sure that if any value is added/removed etc then it will be relected in the orther object too.
    Code:
    rows = askRows;
    It is how OOPs works. This is more of a C# query and beyond what we could support.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks Joydeep,

      Originally posted by NinjaTrader_Joydeep View Post
      The Operations are performed in terms of price. Say, bid price at position 1 is at 1450. Now if the price remains at 1450 however the volume changes then an Update operation will be done. However if the price changes at position 2 then a Remove operation and a Insert operation will be performed.
      So the only purpose is efficiency (and no other purpose)?

      If so, why doesn't OnMarketDepth perform the for loop I described above when OnMarketDepth is called the very first time? This way, bidRows and askRows is populated for every price available, rather than adding one row at at time (which causes the list count to change, instead of remaining fixed).


      Originally posted by NinjaTrader_Joydeep View Post
      If so then the below code in the indicator makes sure that if any value is added/removed etc then it will be reflected in the other object too.
      Code:
      rows = askRows;
      I understand that changes in askRows will now be reflected in rows, but OnBarUpdate uses askRows:

      Code:
      Print("Ask Book");
      				for (int idx = 0; idx < askRows.Count; idx++)
      					Print("Ask Price=" + askRows[idx].Price + " Volume=" + askRows[idx].Volume + " Position=" + idx);
      and I don't see askRows being updated anywhere (e.g askRows = ), despite that OnMarketUpdate seems to modify rows.
      Last edited by :::grimReaper:::; 01-04-2013, 01:52 PM.

      Comment


        #4
        Hello :::grimReaper:::,
        It is also done to reflect the true depth. For example if there are 3 positions (particularly true for a illiquidity instrument) then the list should reflect 3 counts and not 5 or 10 counts (depending on how many depth your data provider provides).




        If you try the below code in a new indicator then what values are you gettiing

        //in variable
        Code:
        List<int> i = new List<int>();

        //in OnBarUpate
        Code:
        Print(i.Count.ToString());
        List<int> ii = i;
        ii.Add(1);
        Print(i.Count.ToString());
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Joydeep View Post
          If you try the below code in a new indicator then what values are you gettiing

          //in variable
          Code:
          List<int> i = new List<int>();

          //in OnBarUpate
          Code:
          Print(i.Count.ToString());
          List<int> ii = i;
          ii.Add(1);
          Print(i.Count.ToString());
          1,1,2,2,3,3

          I see now. rows and bidRows point to the same object, so they both get updated when only one of them updates the object. Thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          671 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X