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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        33 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        50 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X