Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 bortz, 11-06-2023, 08:04 AM
          47 responses
          1,607 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          9 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          19 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          6 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          16 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X