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

Share Service setup

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

    #16
    Hello,

    I got it to work this way:

    if (SystemPerformance.RealTimeTrades.Count > 0)
    {
    // Check to make sure there is at least one trade in the collection
    Trade lastTrade = SystemPerformance.RealTimeTrades[SystemPerformance.RealTimeTrades.Count - 1];
    // Calculate the PnL for the last completed real-time trade
    double lastProfitCurrency = lastTrade.ProfitCurrency;

    if (lastTrade.Exit.Order.OrderState == OrderState.Filled && Position.MarketPosition == MarketPosition.Flat)
    {
    // Pring the PnL to the NinjaScript Output window
    //Print(Time[0] + "The last trade's profit in currency is " + lastProfitCurrency + "Cumulative profit of all trades is: " + " " + SystemPerformance.RealTimeTrades.TradesPerformance .Currency.CumProfit);
    SendMail("*********@txt.att.net", "Last Trade PnL Statement!",string.Format("{0} The last trade's profit in currency is: {1} Profits of all trades is: {2}", Time[0], lastProfitCurrency, SystemPerformance.RealTimeTrades.TradesPerformance .Currency.CumProfit));
    }
    }

    Did I do this correctly?

    Also, two things: Sometimes I don't receive an email until minutes after the trade. And I can't get the real time performance to reset at the close of the session.

    Comment


      #17
      Hi AdeptistJune, thanks for your reply. If you use Print() to print out the data it will confirm if you are getting the correct trade information or not. Use Print() to see when SendMail() is called as well, if you are seeing the print right as the trade is completed and you get a mail message a few minutes later, then it's the mail server being slow. The performance report will not reset until the strategy is disabled. You would need to keep track of the session performance within the script and reset the values when IsFirstBarOfSession= true.
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Skifree, Yesterday, 01:33 PM
      6 responses
      53 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by MJ123, Today, 04:06 PM
      2 responses
      15 views
      0 likes
      Last Post MJ123
      by MJ123
       
      Started by dgutz15, 12-12-2022, 11:50 PM
      4 responses
      65 views
      0 likes
      Last Post drsclaud23  
      Started by xtremel, Today, 08:48 PM
      0 responses
      14 views
      0 likes
      Last Post xtremel
      by xtremel
       
      Started by SilverSurfer1, Today, 08:27 PM
      0 responses
      7 views
      0 likes
      Last Post SilverSurfer1  
      Working...
      X