Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	93
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 fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,406 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    98 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    8 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    160 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    9 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X