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

SystemPerformance.AllTrades.. doesn't work

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

    SystemPerformance.AllTrades.. doesn't work

    running the strategy on the last year data
    have 1 trade per day
    this
    SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitCurrency
    every day gives the same value of the last trade (which was made yesterday 12 Nov 2020)
    I expect that the value will be relevant for the day in the past
    Code:
    bool isNewSession = sessionIterator.IsNewSession(Time[0],true);
    if (isNewSession)
    {
       if (SystemPerformance.AllTrades.Count > 1)    Print (SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitCurrency ); 
    }
    what I get is
    321.12
    321.12
    321.12
    321.12
    321.12
    etc.

    what am I doing wrong please?

    #2
    Hello dadarara,

    Thank you for your post.

    Instead of using a session iterator, please try checking if (SystemPerformance.AllTrades.Count > 0). Then, check to make sure there is at least one trade in the collection using Trade. The code to do so would look as follows.

    Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];

    Finally, print the lastTrade variable to the Output window.

    See the example in the Trade help guide link that demonstrates how this could be done - https://ninjatrader.com/support/help...nt8/?trade.htm

    If you have further questions, please provide an exported example script that demonstrates the behavior you are seeing so that we may further investigate this.

    Let us know if we may further assist.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Brandon

      same thing

      this is the code I use

      Code:
      if (SystemPerformance.AllTrades.Count > 0)
      {
        Trade trade1 = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
        Print( trade1.ProfitCurrency);
      }
      I get
      -391.38
      -391.38
      -391.38
      -391.38
      -391.38

      (changed because today I had a trade with a loss)

      its like the SystemPerformance.AllTrades is looking on the total trades in the system and not in the running strategy ...

      any ideas ?

      Comment


        #4
        Hello dadarara,

        Thank you for that information.

        Please send us an exported example script that demonstrates this behavior so we may further investigate this.

        Thanks in advance, I look forward to resolving this.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          sorry
          my bad
          found the problem
          thank you for your time.
          you guys are amazing your service in invaluable

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Segwin, 05-07-2018, 02:15 PM
          10 responses
          1,769 views
          0 likes
          Last Post Leafcutter  
          Started by Rapine Heihei, 04-23-2024, 07:51 PM
          2 responses
          30 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by Shansen, 08-30-2019, 10:18 PM
          24 responses
          943 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          10 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          7 views
          0 likes
          Last Post rocketman7  
          Working...
          X