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

get the value of a specific range of trades

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

    get the value of a specific range of trades

    hi all,

    Code:
    	 
     double equity = 0;
    foreach( Trade myTrade in SystemPerformance.AllTrades)
    equity = equity + myTrade.ProfitCurrency;
    	  
    Print("l'equity è" + equity);
    with this code im tryng to get a cum profit based on trade objects
    Is it possible to do calculation with a range of Trades?
    for example can i do something like this?
    Code:
    	  double equity = 0;
    	  foreach( Trade myTrade in SystemPerformance.AllTrades[" here a range like trade 1 to  trade 20)
    	  equity = equity + myTrade.ProfitCurrency;
    	  
    	  Print("l'equity è" + equity);
    thank you in advance

    #2
    Hello maxwellreturn,

    There is <TradeCollection>.GetTrades() method.. However, this comes from a position and number of positions ago.


    I don't think this is what you are looking for and I don't think a GetTrades by range exists. It would be necessary to loop through the trades and add these to an array or collection if you would like.

    Would you like to submit a feature request for the NinjaTrader development to consider adding a get trades by range method to the TradeCollection object type in a future version of NinjaTrader?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      yes thank you chelsea,
      it s like create a series where the bars are replaced by trade object

      I don't think this is what you are looking for and I don't think a GetTrades by range exists. It would be necessary to loop through the trades and add these to an array or collection if you would like.
      how can i create an array or a collection in this way?there is some examples? thank you in advance and good year

      Comment


        #4
        Hello maxwellreturn,

        Below I am providing a publicly available link to a 3rd party education site on arrays and lists in C#.
        Create and loop over a string array. Access array Length and get elements at indexes.

        Create a new List, add elements to it, and loop over its elements with for and foreach.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Stanfillirenfro, Yesterday, 09:19 AM
        7 responses
        51 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by TraderCro, 04-12-2024, 11:36 AM
        4 responses
        69 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Mindset, Yesterday, 02:04 AM
        1 response
        15 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by agclub, 04-21-2024, 08:57 PM
        4 responses
        18 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Irukandji, Today, 04:58 AM
        0 responses
        6 views
        0 likes
        Last Post Irukandji  
        Working...
        X