• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    http://ninjatrader.com/support/forum...ead.php?t=3478

    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, 12: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 ksarin, Today, 12:39 PM
          3 responses
          9 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by ttodua, Today, 12:03 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by tomtr27, Today, 11:35 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Uregon, Today, 07:30 AM
          2 responses
          9 views
          0 likes
          Last Post bltdavid  
          Started by Induna, 02-20-2020, 05:38 AM
          4 responses
          26 views
          0 likes
          Last Post NinjaTrader_Kate  
          Working...
          X