Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.Quantity - Stop.Quantity

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

    Position.Quantity - Stop.Quantity

    Hello,

    I learnt from the samplescaleout that I have to scale in when I want to scale out.

    But with scaling in the stops are not shown in total quantity and one can not control in a fast way if there are all stops for the entries because chart trader shows the "last stop" referring the last entry, overlaying the others. So, if entryprice is not the same in fast moving markets one can not see and control the correct stopquantity.

    Is it possible to have somewhere the total # of stops in a trade to plot in the chart window (same as with position.quantity)?

    To control the contracts I do with Position.Quantity in onposition. Can I do somehow also for stops to see if stop quantity is correct? I know I could look for in the orders tab but I think with this great software there could be a better way than "line counting" in a tab.

    By the way I want to comment about chart trader: great thing, as 99,9% with NinjaTrader but why have the lines for entry and stops same length? If one moves stop to BE then one can not see the informations in the entry-price-line. If the lengths would be different one can read all.

    Best regards
    Tony
    Last edited by tonynt; 11-05-2013, 05:06 AM. Reason: sorry, my english;-)

    #2
    Hello tonynt,

    Chart Trader will show the Average Entry Price, so if you have multiple orders scaling in, there is only going to be one Entry Price shown on the Chart which is going to be the "Average Price". So your Stops should be easily calculated because the order quantity is shown just the the left of the Stop Order Name.

    It is possible to calculate this inside of an Automated Strategy as well but it would have to be manually calculated when you are placing the orders. If you let me know how you are placing your Stop orders inside of your Automated Strategy I can try to give you an example of how you can calculate this.

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Hello JC,

      thank you for your response.

      Yes the order quantity is shown on the left, of course, but it is overlaying and one can not control the quantity fast when trading. I have attached a screenshot here to show what I mean.

      As instructed I send to you how the stops are placed:

      if (Position.MarketPosition == MarketPosition.Flat)
      {SetStopLoss("kL1a",CalculationMode.Ticks, 8, false);
      SetStopLoss("kL1b",CalculationMode.Ticks, 9, false);
      SetStopLoss("kL1c",CalculationMode.Ticks, 10, false);}

      I do not know how I can grab and calculate to show as a number in my charts same as I do with positions:

      if(Position.MarketPosition != MarketPosition.Flat)

      DrawTextFixed("Pos", Position.MarketPosition.ToString() + " " + Position.Quantity.ToString(), TextPosition.TopLeft,Color.Black, new Font ("Arial",15), Color.White,Color.White,5);

      Thank you!
      Tony



      Originally posted by NinjaTrader_JC View Post
      Hello tonynt,

      Chart Trader will show the Average Entry Price, so if you have multiple orders scaling in, there is only going to be one Entry Price shown on the Chart which is going to be the "Average Price". So your Stops should be easily calculated because the order quantity is shown just the the left of the Stop Order Name.

      It is possible to calculate this inside of an Automated Strategy as well but it would have to be manually calculated when you are placing the orders. If you let me know how you are placing your Stop orders inside of your Automated Strategy I can try to give you an example of how you can calculate this.

      Happy to be of further assistance.
      Attached Files
      Last edited by tonynt; 11-05-2013, 12:16 PM.

      Comment


        #4
        Hello Tony,

        So you could check for the order quantity inside of OnOrderUpdate() and then Print out that value using the DrawTextFixed() like using Position.Quantity.

        Example:
        Code:
        	int counter = 0;
        
                /// <summary>
                /// Called on each bar update event (incoming tick)
                /// </summary>
                protected override void OnBarUpdate()
                {
        			//Entry Conditions.			
                }
        		
        	protected override void OnOrderUpdate(IOrder order)
        	{
        		if (order.Name == "Stop loss" && order.OrderState == OrderState.Accepted)
        		{
        			counter = counter + order.Quantity;
        			Print("Counter: "+counter);
        		}
        	}
        JCNinjaTrader Customer Service

        Comment


          #5
          Hello JC,

          thank you for your response. I have done as you have shown and in the output window counter goes up to "3" but

          if (order.Name == "Stop loss" && order.OrderState == OrderState.Accepted)
          {
          counter = counter + order.Quantity;
          Print("Counter: "+counter);
          DrawTextFixed("Stops", "\r\n" + "\r\n" + "" + order.Quantity.ToString(), TextPosition.TopLeft,Color.Black, new Font ("Arial",15), Color.White,Color.White,5);
          }
          shows "1" as you can see in the attached screenshot.

          Thank you very much for your support!

          Best regards
          Tony



          Originally posted by NinjaTrader_JC View Post
          Hello Tony,

          So you could check for the order quantity inside of OnOrderUpdate() and then Print out that value using the DrawTextFixed() like using Position.Quantity.

          Example:
          Code:
              int counter = 0;
          
                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                      //Entry Conditions.            
                  }
                  
              protected override void OnOrderUpdate(IOrder order)
              {
                  if (order.Name == "Stop loss" && order.OrderState == OrderState.Accepted)
                  {
                      counter = counter + order.Quantity;
                      Print("Counter: "+counter);
                  }
              }
          Attached Files

          Comment


            #6
            Hello Tony,

            This is because you are using "order.Quantity.ToString()" instead of "counter".

            Also, keep in mind that you will want to add a check when this order is filled or cancelled so that you can subtract the quantity from "counter" to keep the correct number inside of our Script.

            Happy to be of further assistance.
            JCNinjaTrader Customer Service

            Comment


              #7
              Hello JC,

              thank you for your reply. Sorry for my error with order.quantity.

              In the meantime I have added to check for filled and cancelled orders. This works.

              But I have an issue when I change my stops. Eg when I move my 3 initial stops to BE then the order.quantity and counter show "6". This is logical, but does not show the real quantity of stops. How can I avoid this please when changing the stops?

              Thank you!
              Tony

              Originally posted by NinjaTrader_JC View Post
              Hello Tony,

              This is because you are using "order.Quantity.ToString()" instead of "counter".

              Also, keep in mind that you will want to add a check when this order is filled or cancelled so that you can subtract the quantity from "counter" to keep the correct number inside of our Script.

              Happy to be of further assistance.

              Comment


                #8
                Hello Tony,

                Correct, that would be logical. You would not be able to avoid this, but what you can do is that when the order is in the "PendingChange" state you may want to subtract the order quantity from "counter" so when it becomes "Accepted" again NinjaTrader will add the order quantity back so that it stays constant.
                JCNinjaTrader Customer Service

                Comment


                  #9
                  Hello JC,

                  thank you for your response. Therefore I do with a flag. Seems to work (different ways like "if orderqty = certainvalue" or "if orderqty=Position.qty" or maybe some other. Then I change flag. In onorderupdate I add the "flagcondition" that is not true then and no count anymore....

                  Thank you again for all your support!

                  It´s great to trade with NinjaTrader and great to get this support with all of you!

                  Best regards
                  Tony

                  Originally posted by NinjaTrader_JC View Post
                  Hello Tony,

                  Correct, that would be logical. You would not be able to avoid this, but what you can do is that when the order is in the "PendingChange" state you may want to subtract the order quantity from "counter" so when it becomes "Accepted" again NinjaTrader will add the order quantity back so that it stays constant.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by zstheorist, Today, 07:52 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post zstheorist  
                  Started by pmachiraju, 11-01-2023, 04:46 AM
                  8 responses
                  149 views
                  0 likes
                  Last Post rehmans
                  by rehmans
                   
                  Started by mattbsea, Today, 05:44 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post mattbsea  
                  Started by RideMe, 04-07-2024, 04:54 PM
                  6 responses
                  33 views
                  0 likes
                  Last Post RideMe
                  by RideMe
                   
                  Started by tkaboris, Today, 05:13 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post tkaboris  
                  Working...
                  X