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.GetTrades

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

    SystemPerformance.AllTrades.GetTrades

    private double MyStrategyEntry1Performance;


    MyStrategyEntry1Performance = SystemPerformance.AllTrades.GetTrades("ES 09-22","Entry1", 1);

    Get compile error = "Cannot implicity convert type NinjaTrader.cbi.TradeCollection"to double".

    How do I access that collection in a strategy...

    For example:

    if SystemPerformance.AllTrades.GetTrades("ES 09-22","Entry1", 1); > 100
    then do this.



    Many thanks guys.

    #2
    Hello elliot5,

    Thanks for your post.

    SystemPerformance.AllTrades.GetTrades() is a TradeCollection, not a double variable. You would need to assign GetTrades() to a TradeCollection variable.

    For example, see the sample code below.

    Code:
    TradeCollection myTrades = SystemPerformance.AllTrades.GetTrades("AAPL", "entrySignal", 1);
    See this help guide page for more information about SystemPerformance.AllTrades.GetTrades() and sample code: https://ninjatrader.com/support/help.../gettrades.htm

    Let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      OK thanks -
      but then using the logic

      if(myTrades >0)
      then do this


      Gives Compile error "Operator <= cannot be applied to operands of type NTtradecollection and int"
      Do I have to declare in variables the myTrades variable?

      regards and thx

      Comment


        #4
        Hello elliot5,

        Thanks for your note.

        Since SystemPerformance.AllTrades.GetTrades() is a TradeCollection, you would not be able to compare it to an int value.

        You could assign GetTrades() to a TradeCollection as seen in my previous post and then use <TradeCollection variable>.Count to get the number of trades as an int value.

        Code:
        TradeCollection myTrades = SystemPerformance.AllTrades.GetTrades("AAPL", "entrySignal", 1);
        int myTradesCount = myTrades.Count;
        myTradesCount could be compared to an int value, such as 0.

        An example of using <TradeCollection variable>.Count could be seen in the GetTrades() help guide page linked in post # 2.

        Let me know if I may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          No I specifically need to know if P&L is positive today for a specific signal......

          Comment


            #6
            Hello elliot5,

            Thanks for your note.

            GetTrades() returns a TradePerformance object as noted in the help guide.

            You could use the local variable you made and access the TradesPerformance values of that variable.

            For example, if you have a local variable called myTrades, you could use something like myTrades.TradesPerformance.Currency.CumProfit.

            Please review the help guide documentation below about the TradesPerformance values you could access and sample code.

            TradesPerformance: https://ninjatrader.com/support/help...erformance.htm
            TradesPerformance Values: https://ninjatrader.com/support/help...ancevalues.htm

            Let me know if I may assist you further.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Thank you . I am aware of this but as it does not return a double or int - how can I use it in trade logic? Regards and thanks

              Comment


                #8
                Hello elliot5,

                Thanks for your note.

                The myTrades.TradesPerformance.Currency.CumProfit code mentioned in my previous post does return a double value. This is seen in the TradesPerformance.Currency.CumProfit help guide page linked below.

                TradesPerformance.Currency.CumProfit: https://ninjatrader.com/support/help.../cumprofit.htm

                Let me know if I may further assist.
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  Ok but I need the cumprofit from a specific signal - is that possible? Regards and thanks

                  Comment


                    #10
                    Hello elliot5,

                    Thanks for your note.

                    You could consider assigning GetTrades() to a TradeCollection variable named something like myTrades to get the trade of a specific signal.

                    Then, you would access the TradesPerformance values of the variable holding the trade of a specific signal. For example, myTrades.TradesPerformance.Currency.CumProfit, seen in post # 6.

                    See the help guide documentation below.
                    SystemPerformance.AllTrades.GetTrades(): https://ninjatrader.com/support/help.../gettrades.htm
                    TradesPerformance.Currency.CumProfit: https://ninjatrader.com/support/help.../cumprofit.htm

                    Please let me know if I may further assist.
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      yes that is very helpful thankyou - much appreciated.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by rhyminkevin, Today, 04:58 PM
                      3 responses
                      47 views
                      0 likes
                      Last Post Anfedport  
                      Started by iceman2018, Today, 05:07 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post iceman2018  
                      Started by lightsun47, Today, 03:51 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post lightsun47  
                      Started by 00nevest, Today, 02:27 PM
                      1 response
                      14 views
                      0 likes
                      Last Post 00nevest  
                      Started by futtrader, 04-21-2024, 01:50 AM
                      4 responses
                      50 views
                      0 likes
                      Last Post futtrader  
                      Working...
                      X