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 Caspersky_, 06-18-2024, 12:22 PM
      7 responses
      33 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by llanqui, Today, 03:17 AM
      3 responses
      10 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by Potato Cakes, Today, 05:35 AM
      0 responses
      5 views
      0 likes
      Last Post Potato Cakes  
      Started by ttodua, 06-18-2024, 12:33 PM
      4 responses
      13 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by TanyaD, 06-17-2024, 10:07 AM
      5 responses
      22 views
      0 likes
      Last Post TanyaD
      by TanyaD
       
      Working...
      X