Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best way to get PnL of most recent trade?

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

    Best way to get PnL of most recent trade?

    In the OnExecution() event, what's the best way to get the PnL of the most recent trade (when I don't have the OrderID)?

    BACKGROUND:
    In my strategy, in the OnBarUpdate(), I execute EnterLong() or EnterShort(). So, in the OnExecution() event, I want to send email and include the PnL of the most recent trade.

    #2
    Off the top of my head, I am not sure. I suggest printing out all values on the execution object passed in and inspect them to see what you may be able to use.
    RayNinjaTrader Customer Service

    Comment


      #3
      This will do it for me.

      Perfermance.AllTrades[0] refers to the last executed trade.

      protected override void OnExecution(IExecution execution)
      {
      Trade lastTrade = Performance.AllTrades[0];
      if (lastTrade != null) SendNotification(lastTrade.ProfitPoints.ToString() )
      }

      (SendNotification is my helper procedure that sends email)

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      290 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      185 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      184 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      267 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      217 views
      0 likes
      Last Post CarlTrading  
      Working...
      X