Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Filled vs. Quantity

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

    #16
    Thanks Josh,
    If it behaves as you stated then its OK.

    Baruch

    Comment


      #17
      Hi,
      One more question. How do you distinguish btw. longs and short?
      The sample strategy shows only longs.
      Code:
              protected override void OnExecution(IExecution execution)
              {
         /* We advise monitoring OnExecution to trigger submission of stop/target orders instead of OnOrderUpdate() since OnExecution() is called after OnOrderUpdate()
         which ensures your strategy has received the execution which is used for internal signal tracking. */
         if (entryOrder != null && entryOrder.Token == execution.Order.Token)
         {
          if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
          {
           // Stop-Loss order 4 ticks below our entry price
           stopOrder  = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 4 * TickSize, "MyStop", "MyEntry");
           
           // Target order 8 ticks above our entry price
           targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 8 * TickSize, "MyTarget", "MyEntry");
           
           // Resets the entryOrder object to null after the order has been filled or partially filled
           if (execution.Order.OrderState != OrderState.PartFilled)
           {
            entryOrder  = null;
           }
          }
         }
         
         // Reset our stop order and target orders' IOrder objects after our position is closed.
         if ((stopOrder != null && stopOrder.Token == execution.Order.Token) || (targetOrder != null && targetOrder.Token == execution.Order.Token))
         {
          if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled)
          {
           stopOrder = null;
           targetOrder = null;
          }
         }
        }

      Comment


        #18
        Hi Baruch,

        You need to create separate order objects for shorts. The sample is written to illustrate the principles, but you can name objects whatever you like and create additional ones.

        Code:
        if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
        {
        // Stop-Loss order 4 ticks below our entry price
        longStopOrder  = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 4 * TickSize, "MyLongStop", "MyLongEntry");
        [COLOR="Red"]shortStopOrder  = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 4 * TickSize, "MyShortStop", "MyShortEntry");[/COLOR]
             
        // Target order 8 ticks above our entry price
        longTargetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 8 * TickSize, "MyTarget", "MyEntry");
             
        // Resets the entryOrder object to null after the order has been filled or partially filled
        if (execution.Order.OrderState != OrderState.PartFilled)
        {
        entryOrder  = null;
        }
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #19
          Rayn hi,
          You didn't understand my question. The question is how do you know when to execute a longstop and when a shortstop? How do you know if the original order is a long or a short?

          Baruch

          Comment


            #20
            You can check the execution.Order.Name of the order being filled. If it is the long order then submit your long ones. If it is the short one, do the short stops.
            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
            647 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            368 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            571 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X