Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Not working on Strategies Tab

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

    Not working on Strategies Tab

    The following does not work when applied to the Strategies tab

    It's working when applied to the chart.

    For some reason, I need it to work on the strategies tab.


    if (SystemPerformance.RealTimeTrades.Count > 0)
    {
    // Check to make sure there is at least one trade in the collection
    Trade lastTrade = SystemPerformance.RealTimeTrad es[SystemPerformance.RealTimeTrades.Count - 1];

    // Calculate the PnL for the last completed real-time trade
    double lastProfitCurrency = lastTrade.ProfitCurr ency;

    // Store the quantity of the last completed real-time trade
    double lastTradeQty = lastTrade.Quantity;

    // Pring the PnL to the NinjaScript Output window
    Print("The last trade's profit in currency is " + lastProfitCurrency);
    // The trade profit is quantity aware, we can easily print the profit per traded unit as well
    Print("The last trade's profit in currency per traded unit is " + (lastProfitCurrency / lastTradeQty));
    }

    Any workaround, please.

    Your help would be much appreciated!

    Thanks

    #2
    Nevermind,

    When I put the "IncludeTradeHistoryInBacktest = true;" to SetDefaults, it does not populate.

    But when I transferred it to Configure, it works.

    Comment


      #3
      Hello Danville.Sumobay,

      Thanks for your post.

      Please note that if you make changes to State.SetDefaults, you will likely need to remove and re add the script in order for the changes to be loaded. State.Configure will happen later in the script's life where a remove and re-add would not be needed.

      OnStateChange - https://ninjatrader.com/support/help...tatechange.htm

      Understanding NinjaScript LifeCycle - https://ninjatrader.com/support/help...fecycle_of.htm

      We look forward to assisting.

      Comment

      Latest Posts

      Collapse

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