Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IOrder and OCO

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

    IOrder and OCO

    Hello,
    Since SetStopLoss() and SetProfitTarget() don’t return an IOrder object, am I right to assume that if I want to do any special handling with these orders that I should use functions that return IOrder such as ExitLongStop() instead?.

    SetStopLoss() and SetProfitTarget() look to be an easy way to get the order out there, but you lose some flexibility in the process – such as not being able to check which order was filled/canceled in OnOrderUpdate().

    Also, if I create my own stop orders for targets and stops, does the OCO functionality come from the signalName, or is this specified in the IOrder object?

    Thanks,

    -Scott

    #2
    Scott,

    OnOrderUpdate() is called and an IOrder object is passed in. You can "capture" a reference to the IOrder objects generated by the SetStopLoss() and SetProfitTarget() methods by monitoring OnOrderUpdate(). We do have it on our list to publish a reference sample sooner than later. For now, just run some tests to see what the IOrder.Name property reveals. I believe the info should be sufficient. Keep in mind that there can be multiple stop orders generated for a single call to SetStopLoss() since by default, a stop loss order is generated for each incoming fill of an entry order.

    OCO functionality from ExitLongStop() type method calls is based on the some internal signal name mapping.
    RayNinjaTrader Customer Service

    Comment


      #3
      Ray,

      Thanks for the info, and that's what I expected. I just didn't want to find myself in a position where my code breaks because I was using something "undocumented".

      Thanks for the quick reply...

      -Scott

      Comment


        #4
        I should add..

        Although you can capture a reference via my explanation...Do not count on any properties that are dynamic (OrderState, AvgFillPrice etc..) to be updated. This object is volatile and should only be used to get static properties of the IOrder object.

        Hope this makes sense.
        RayNinjaTrader Customer Service

        Comment


          #5
          How to reference the IOrder object of SetStopLoss() and SetStopTarget() ?

          Hi! I would like to reference the IOrder object of the SetProfitTarget() in a strategy. I read in post #2 below that
          it is possible to "capture" a reference to the IOrder objects generated by the SetStopLoss() and SetProfitTarget() methods by monitoring OnOrderUpdate().
          How can I "monitor OnOrderUpdate()" ? I'v tried with this code but I don't se any IOrder name that refers to my SetProfitTarget() order in the output window. What could the names of the IOrder objects be approximately?

          Code:
          protected override void OnOrderUpdate(IOrder order)
                  {
                      if (EnterLong1a != null && EnterLong1a.Token == order.Token
                          ||
                          EnterLong1b != null && EnterLong1b.Token == order.Token
                          ||
                          EnterShort1a != null && EnterShort1a.Token == order.Token
                          ||
                          EnterShort1b != null && EnterShort1b.Token == order.Token)
                      
                         {
                          Print(order.ToString());
                      }
                  }
          The strategy in question uses 2 entry orders to scale out of the position. When the SetProfitTarget() order that's tied to the firts entry order is hit (IOrder == null) I want to modify the SetStopLoss() order that's tied to the seccond entry order.
          Last edited by poseidon_sthlm; 01-11-2010, 09:05 AM.

          Comment


            #6
            poseidon_sthlm, please work alongside this sample below - http://www.ninjatrader-support2.com/...ead.php?t=5790

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            628 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            359 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            562 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X