Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to do math on Array elements?

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

    How to do math on Array elements?

    I made an Array called myRangeArray[47] with 48 slots- one for each 30 minute TPO time period. I used Date.Time conditionals to store range values for 1/2 hour bars ending at 1:30am 013000 in myRangeArray[2] slot 2 for example. So i have right data in right place. But my question is how can i take the average of all numbers in slot [2]? How can 2 std deviation be calced? In short, how can a person do math on the list of doubles in a slot? thanks!
    Last edited by Kicks.Spin; 01-07-2022, 08:16 AM.

    #2
    Hi Kicks.Spin, thanks for posting.

    I found several links through a google search on taking the average of a C# array here (publicly available):

    The Average() method in C# calculates the arithmetic mean of a sequence of numeric values. This method is part of LINQ (Language Integrated Query) and can be used with arrays, lists, and other enumerable collections.

    Given an array and we have to find the average of all array elements using C# program.


    Kind regards,
    -ChrisL

    Comment


      #3
      I don't fully understand what you're doing but, I recommend this library which I use a lot:



      Code:
      Statistics.Mean(slot[2])
      Statistics.PopulationStandardDeviation(slot[2]) * 2
      might be what you need

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      165 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      88 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      128 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      208 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      185 views
      0 likes
      Last Post CarlTrading  
      Working...
      X