Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicators and OnOrderUpdate

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

    Indicators and OnOrderUpdate

    ​​Hello devs,

    I am trying to get pop up a message from am indiciador when my stop loss is filled (I am placing the Stop loss from an ATM strategy) where I am subscribing the account to the OnOrderUpdate event, it is being fired ok doing the code below

    Code:
    private void OnOrderUpdate(object sender, OrderEventArgs e)
    {
         if (e.Order.Account == account1)
         {
         if (e.OrderState == OrderState.Filled && e.Order.IsStopMarket == true || e.OrderState == OrderState.Filled && e.Order.IsStopLimit == true)
         {
              MessageBox.Show("STOP LOSS MESSAGE");
         }
         }
    }

    but sometimes using the code above, it filled the stop loss (the order disappears) but the trade keeps open, and the trade without any stop loss. (still showing the Limit order for the target)

    In order appears in this way:
    Click image for larger version

Name:	stop.PNG
Views:	164
Size:	37.6 KB
ID:	1176803

    I thought it was something related to timing when the event is fired it blocks in some way the orders, then I change the message box line for an enabling a timer and show the Messagebox after 2secs, but it still has the same behavior 2/10 times when I tested it, I only tested it on demo no in live accounts at the moment

    any suggestion or workaround


    Regards.





    Attached Files

    #2
    Hello alejandro888,

    This would be general c#, as NinjaTrader has a NTMessageBoxSimple.


    To confirm, you are showing the order as filled on the Orders tab of the Control Center, but you are seeing the Position showing on the Positions tab of the Control Center?

    Or you are printing the position from the <Account>.PositionUpdate event?

    The other issue may be that the c# message box is a thread blocking event. You might need to open this on a different thread.

    Alternatively, you could use the already existing Alerts window.

    Last edited by NinjaTrader_ChelseaB; 10-31-2021, 04:45 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    553 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    100 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    543 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    546 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X