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

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.
      JimNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by kujista, Today, 06:23 AM
      3 responses
      6 views
      0 likes
      Last Post kujista
      by kujista
       
      Started by Mindset, Yesterday, 02:04 AM
      2 responses
      17 views
      0 likes
      Last Post NinjaTrader_RyanS  
      Started by f.saeidi, Today, 08:03 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by samish18, 04-17-2024, 08:57 AM
      15 responses
      52 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by f.saeidi, Today, 08:13 AM
      0 responses
      1 view
      0 likes
      Last Post f.saeidi  
      Working...
      X