Announcement

Collapse
No announcement yet.

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.

      Comment


        #18
        Hi AdeptistJune, can you please share the code for mail shared service and maybe a guide or a link how to implement it in the NT8. I'm not very technical unfortunately.

        Thanks in advance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        93 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        138 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        123 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        73 views
        0 likes
        Last Post PaulMohn  
        Working...
        X