Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trade details on order closed

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

    Trade details on order closed

    Hi

    I am trying to write some code that will get called when an open order is closed (in other words when an existing open position is closed, resulting in a profit or loss).

    I am planning to use the OnOrderUpdate event for this purpose, is this correct? What states of the IOrder object do I need to check so that my code only responds when an order is closed?

    Also, I don't see any properties on the IOrder or IExecution interfaces that would tell me what the closed trade's profit/loss and maximum drawdown was?

    Many thanks

    #2
    Hi Ravish, if you're interested in the position update event, then OnPositionUpdate() would be ideal - http://www.ninjatrader.com/support/h...tionupdate.htm

    Another option is checking directly for the execution event of your positon exit order, for example the stoploss or the target, that would be done via the IOrder objects in OnExecution() -



    A full working reference sample for this advanced management technique for your orders and positions would be offered here - http://www.ninjatrader.com/support/f...ead.php?t=7499

    Accessing performance info / stats would be possible via the Trade collections and Performance classes - http://www.ninjatrader.com/support/h...collection.htm

    Comment


      #3
      Thanks Bertrand, I'll look at these recommendations.

      I don't see anything in the Trade collections and Performance classes about drawdown, only PnL. When you backtest a strategy, the resulting report contains information about the strategy's maximum drawdown, so I'm assuming it must be calculated somewhere...?

      Comment


        #4
        Correct, the drawdown for the historical and / or realtime collections of trades would be available, too - http://www.ninjatrader.com/support/h...7/drawdown.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        67 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        36 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        60 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X