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

Unmanaged stop/profit orders

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

    Unmanaged stop/profit orders

    Hello,

    I'm using an unmanaged approach. I've looked at the reference sample for SampleMonitorStopProfit:

    http://www.ninjatrader.com/support/f...ead.php?t=5790 which contains this portion in OnOrderUpdate:

    protected
    overridevoid OnOrderUpdate(IOrder order)
    {
    // If OnOrderUpdate() is called from a stop loss or profit target order add it to the appropriate collection
    if (order.OrderState == OrderState.PendingSubmit)
    {
    // Add the "Stop loss" orders to the Stop Loss collection
    if (order.Name == "Stop loss")
    stopLossOrders.Add(order);

    In SampleOnOrderUpdate reference sample, it says to use this in OnExecution

    protected
    overridevoid 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 == execution.Order)
    {
    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");


    I'm trying to determine if both of these reference samples are compatible.
    Is the use of
    Code:
    stopLossOrders.Add(order);
    still best to use within OnOrderUpdate or should it be moved to the OnExecution section.
    Last edited by zeller4; 02-23-2011, 11:48 AM.

    #2
    Hello,

    Thanks for the forum post.

    Yes you can combine them both.

    Reason is that the OnOrderUpdate simply adds the Submitted stop loss to be stored correctly in a list that it is a profit target or a stop loss.Which does no order submission and is just for internal tracking.

    Then You would use either SetStopLoss() to submit your stop or submitt it manually with the unmanaged version with SubmitOrder() or ExitLongStop().

    Let me know if I can be of further assistance.

    Comment


      #3
      Thanks Brett,

      So, for the stop and target, I have these in OnExecution:
      Code:
      [FONT=Courier New][SIZE=2][COLOR=#0000ff]
      [SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] (entryOrder_1a != [/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] && entryOrder_1a == execution.Order)[/COLOR][/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (execution.Order.OrderState == OrderState.Filled || [/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]execution.Order.OrderState == OrderState.PartFilled || [/FONT][/SIZE]
      [SIZE=2][FONT=Courier New](execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]))[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
       
      [/SIZE][/FONT]if[/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] (Position.MarketPosition == MarketPosition.Long) inTradeLong = [/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000];[/COLOR][/SIZE][/FONT][/SIZE][/FONT]
      [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] minStop = (MIN(Low,[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]]-[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]*TickSize);[/SIZE][/FONT]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] stop = Math.Max(minStop,(execution.Order.AvgFillPrice - stopTicks * TickSize));[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]//Math.Min(Close[0] - TickSize, Math.Max(l - TickSize, execution.Order.AvgFillPrice - stopTicks * TickSize));[/COLOR][/SIZE][/FONT]
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (stopOrder_1a == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] && stop > [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) stopOrder_1a = SubmitOrder([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], OrderAction.Sell, OrderType.Stop, execution.Order.Filled, stop, stop, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Exit_1a"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"LongStop_a1"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
       
      [/SIZE][/FONT][/COLOR]
      [/SIZE][/FONT][/SIZE][/FONT]
      Code:
      [FONT=Courier New][SIZE=2][COLOR=#0000ff]
      [SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff]double[/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] target = (execution.Order.AvgFillPrice + targetTicks * TickSize);[/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]//Math.Max(Close[0] + TickSize, execution.Order.AvgFillPrice + targetTicks * TickSize);[/COLOR][/SIZE][/FONT]
      [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (targetOrder_1a == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] && target > [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) targetOrder_1a = SubmitOrder([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], OrderAction.Sell, OrderType.Limit, execution.Order.Filled, target, target, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Exit_1a"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"LongTarget_a1"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
       
      [/SIZE][/FONT]
      Last edited by zeller4; 02-23-2011, 11:46 AM.

      Comment


        #4
        Not sure if these are correctly placed in OnExecution also?
        Code:
        [SIZE=2][FONT=Courier New][COLOR=#008000][SIZE=2][FONT=Courier New][COLOR=#008000][SIZE=2][FONT=Courier New][COLOR=#008000]// Resets the entryOrder object to null after the order has been filled or partially filled[/COLOR][/FONT][/SIZE]
        [/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] (execution.Order.OrderState != OrderState.PartFilled)[/COLOR][/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
        [SIZE=2][FONT=Courier New]entryOrder_1a = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
        [/SIZE][/FONT]
        Code:
        [SIZE=2][FONT=Courier New][COLOR=#008000][SIZE=2][FONT=Courier New][COLOR=#008000][SIZE=2][FONT=Courier New][COLOR=#008000]// Reset our stop order and target orders' IOrder objects after our position is closed.[/COLOR][/FONT][/SIZE]
        [/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] ((stopOrder_1a != [/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] && stopOrder_1a == execution.Order) || [/COLOR][/SIZE][/FONT]
        [SIZE=2][FONT=Courier New](targetOrder_1a != [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] && targetOrder_1a == execution.Order))[/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
        [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (execution.Order.OrderState == OrderState.Filled || [/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]execution.Order.OrderState == OrderState.PartFilled)[/FONT][/SIZE]
        [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
        [SIZE=2][FONT=Courier New]stopOrder_1a = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]targetOrder_1a = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]inTradeLong = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
        [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
         
        [/SIZE][/FONT]
        Do you see any other lines of code I need to add or move around?
        Have any Reference Samples been created to show the Unmanaged approach?

        from Post #1, what is the method or any other reason to "call" the Name "Stop loss" i.e how does that name relate to the name I give my stop loss in post #3 - can you please give an example with the correct syntax? Thanks
        Code:
        [FONT=Courier New][COLOR=#008000]// Add the "Stop loss" orders to the Stop Loss collection[/COLOR][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] (order.Name == [/SIZE][/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"Stop loss"[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
        [/SIZE]
        Last edited by zeller4; 02-23-2011, 12:06 PM.

        Comment


          #5
          Brett,

          When trying to add this "Add" to the OnOrderUpdate, it gives error message that Cbi.IOrder doesn't contain a definition for Add... (I have NT7 latest version)

          I created
          Code:
          [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]
          [SIZE=2][FONT=Courier New][COLOR=#0000ff]private[/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] IOrder stopLossOrders = [/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000];[/COLOR][/SIZE][/FONT]
           
          [/SIZE][/FONT]
          Code:
          [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]
          [SIZE=2][FONT=Courier New][COLOR=#0000ff]protected[/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] OnOrderUpdate(IOrder order)[/COLOR][/SIZE][/FONT]
          [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
          [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// If OnOrderUpdate() is called from a stop loss or profit target order add it to the appropriate collection[/COLOR][/SIZE][/FONT]
          [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (order.OrderState == OrderState.PendingSubmit)[/SIZE][/FONT]
          [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
          [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// Add the "Stop loss" orders to the Stop Loss collection[/COLOR][/SIZE][/FONT]
          [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (order.Name == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Stop loss"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
          [SIZE=2][FONT=Courier New]stopLossOrders.Add(order);[/FONT][/SIZE]
          [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
          [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
          [/SIZE][/FONT]
          Trying to understand how to use this / make it work.
          Kirk

          Comment


            #6
            Hi Kirk,

            Set statements cannot be used with unmanaged approach. You should see a message to this effect in the log tab of control center when using them with unmanaged strategy. The reference sample you're using is only used for monitoring stop loss orders submitted with Set statements so is not compatible with unmanaged approach.

            Please let us know if you would like additional clarification.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              In the second message of this thread there was a statement made:

              "Then You would use either SetStopLoss() to submit your stop or submit it manually with the unmanaged version with SubmitOrder() or ExitLongStop()."

              Is "ExitLongStop()" an unmanaged version?

              If I reference the Help manual, I don't see "ExitLongStop()" listed under the Unmanaged Approach.

              taddypole...

              Comment


                #8
                Taddypole, ExitLongStop() would be for managed strategies only. Sorry for the confusion.
                AustinNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by geddyisodin, 04-25-2024, 05:20 AM
                8 responses
                59 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by jxs_xrj, 01-12-2020, 09:49 AM
                4 responses
                3,285 views
                1 like
                Last Post jgualdronc  
                Started by Option Whisperer, Today, 09:55 AM
                0 responses
                5 views
                0 likes
                Last Post Option Whisperer  
                Started by halgo_boulder, 04-20-2024, 08:44 AM
                2 responses
                22 views
                0 likes
                Last Post halgo_boulder  
                Started by mishhh, 05-25-2010, 08:54 AM
                19 responses
                6,189 views
                0 likes
                Last Post rene69851  
                Working...
                X