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:	169
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 sjsj2732, Today, 04:31 AM
    0 responses
    20 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    280 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    279 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    130 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    90 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X