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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X