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
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:
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.
Comment