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 NullPointStrategies, Today, 05:17 AM
    0 responses
    20 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    119 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X