Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Count vs TradeCount?

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

    Count vs TradeCount?


    Folks, what is the difference between Count and TradeCount? For example, there is:


    SystemPerformance.RealTimeTrades.Count
    SystemPerformance.RealTimeTrades.TradeCount


    I notice the example code uses both, seemingly interchangeably. I have a section of code:

    Print SystemPerformance.RealTimeTrades.Count
    Print SystemPerformance.RealTimeTrades.TradeCount​
    if (SystemPerformance.RealTimeTrades.TradeCount > 0)
    Print SystemPerformance.RealTimeTrades[TradeCount - 1].ProfitCurrency

    and after the first trade has concluded, I get:

    0
    1
    Error: You are access an index with a value that is out-of-range


    Thanks,








    #2
    Hello timmbbo,

    Count is the C# count of the collection, the number of items in the collection. TradeCount is a custom property relating to the number of trades.

    The error you are getting is because you are trying to access an index that does not exist in the collection.

    Comment


      #3

      Jesse, thanks, that helps, though it still leaves me with the base problem. My TradeCount is 1, but I can not access the first trade element. My code is:

      Print SystemPerformance.RealTimeTrades.TradeCount
      Print SystemPerformance.RealTimeTrades[SystemPerformance.RealTimeTrades.TradeCount - 1].ProfitCurrency

      and I get

      1
      Can not access an index with a value that is invalid since it is out of range.

      Since my TradeCount is 1, there should be a valid TradeCollection element at index 0. Yet, attempting to access that element gives me this error.

      Your thoughts? Thanks,







      Comment


        #4
        Hello timmbbo,

        If you are trying to select a specific trade you would want to use the Count but only after the count is more than 0, there is a sample that shows that here:

        Comment


          #5

          Jesse, thanks, I'm making that update now. Last question:

          Why would Count be different from TradeCount? Right after I complete my first trade, the RealTimeTrades.TradesCount is 1, and RealTimeTrades.Count is 0. Since I've just completed a trade, it seems like both should be 1. Why the difference?

          Thanks,

          Comment


            #6
            Hello timmbbo,

            I wouldn't be able to say why that may be different however f you are trying to use the collection in some way you would want to use the count of the collection specifically which is Count.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            48 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            126 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            66 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X