Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SampleOnOrderUpdate

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

    SampleOnOrderUpdate

    In the example of the SampleOnOrderUpdate, it gives an example of how to monitor a long position.

    // Update our exit order quantities once orderstate turns to filled and we have seen execution quantities match order quantities
    else if (execution.Order.OrderState == OrderState.Filled && sumFilled == execution.Order.Filled)
    {
    // Stop-Loss order for OrderState.Filled
    stopOrder = ExitLongStopMarket(0, true, execution.Order.Filled, execution.Order.AverageFillPrice - 4 * TickSize, "MyStop", "MyEntry");
    targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AverageFillPrice + 8 * TickSize, "MyTarget", "MyEntry");
    }
    // Update our exit order quantities once orderstate turns to filled and we have seen execution quantities match order quantities
    else if (execution.Order.OrderState == OrderState.Filled && sumFilled == execution.Order.Filled)
    {
    // Stop-Loss order for OrderState.Filled
    stopOrder = ExitLongStopMarket(0, true, execution.Order.Filled, execution.Order.AverageFillPrice - 4 * TickSize, "MyStop", "MyEntry");
    targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AverageFillPrice + 8 * TickSize, "MyTarget", "MyEntry");
    }

    How would I code those lines of code to manage a short position?

    Also, and how would I code the example if I have multiple entry signals?

    Thanks,

    #2
    Hello AdeptistJune,

    In the code you have extracted you can see the order names which would be how you find orders in OnOrderUpdate or OnExecutionUpdate. If you have multiple orders you just look for the order name which you want.

    That sample only has a few variables, if you wanted to expand it to support many orders you could create more variables and then make many conditions inside OnorderUpdate to find specific order names.
    You can see a sample of using the name here: https://ninjatrader.com/support/help...=onorderupdate

    Code:
    if (order.Name == "MyLongEntry")
        myLongEntryVariable  = order;

    Please let me know if I may be of additional assistance

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    89 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X