Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Specify Order Name With OnExecutionUpdate?

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

    Specify Order Name With OnExecutionUpdate?

    Hello! I'm at the stage in my strategy's development that I'd like to get into some advanced order handling.

    If using the OnExecutionUpdate() function, can an Order Name be specified and if so, how?

    I've given different entries different Names and would like entry A to have a different set of exit conditions than entry B.

    Is there a better function to use in this scenario?


    #2
    Hello trilliantrader,

    Yes the name can be specified, that is known as the orders signal name. When you call an entry method you can supply a orders name.

    EnterLong(string signalName)

    ​In OnExecutionUpdate you would see the orders name as the execution name.

    Comment


      #3
      Ok, so if I have in a pervious statement

      EnterLong (string signalA)

      Can I specify this order "signalA" in the next if statement?

      if (execution.Order.OrderState == OrderState.Filled && sumFilled == execution.Order.Filled)

      ​If so, how?

      Comment


        #4
        Hello trilliantrader,

        Yes you would check for execution.Name == "YourSignalName"

        Comment


          #5
          Hi Jesse, I have entered the order with EnterShortStopMarket under protected override void OnBarUpdate(). For profit-taking & stop-loss orders, I entered via protected override void OnExecutionUpdate (as my main data series is 5-min and I would like to exit via a 1-min timeframe). I tried to check whether the trade exited via the profit-taking or stop-loss orders in the Output window, yet it did not work. Which part does it go wrong?


          protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
          {
          ExitLongLimit(1, true, quantity, profit-taking price, "LongProfitTaking", "LongEntry");
          if (execution.Order.Name == "LongProfitTaking")
          {
          Print("Proft-taking");
          }

          ExitLongStopMarket(1, true, quantity, stop-loss price, "LongStopLoss", "LongEntry");
          if (execution.Order.Name == "LongStopLoss")
          {
          Print("Stop-loss");
          }

          Comment


            #6
            Hello morong0414,

            Have you tried printing the execution to check what the name is listed as?

            Code:
            protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
            {​
            
                Print(execution.Order.Name );

            Additionally you should not have ExitLongLimit inside of OnExecutionUpdate without a condition like you have shown, that would be called for every execution including their own so it would resubmit the exit again when it fills which may cause an inflight execution.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            79 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            40 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            63 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            63 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X