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

How to get the highest and lowest value from a group of indicators?

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

    How to get the highest and lowest value from a group of indicators?

    How to get the highest and lowest value from a group of indicators?

    So I have a group of indicators to compare values.
    SMA1[0], SMA2[0], SMA3[0], EMA1[0], EMA2[0], EMA3[0]

    I would like to reach to this point:

    Code:
    If
    (
    (HighestValue - LowestValue) >  0.001)
    )
    {
       // do this
    }
    Thank you!

    #2
    Originally posted by johnnybegoode View Post
    How to get the highest and lowest value from a group of indicators?

    So I have a group of indicators to compare values.
    SMA1[0], SMA2[0], SMA3[0], EMA1[0], EMA2[0], EMA3[0]

    I would like to reach to this point:

    Code:
    If
    (
    (HighestValue - LowestValue) > 0.001)
    )
    {
    // do this
    }
    Thank you!
    Offhand, I can think of any of 3 ways:
    1. Put them in a list; sort the list; use first and last values of the sorted list.
    2. Put them in a list and use LINQ to get the max and min values
    3. Use a succession of Math.Max() and Math.Min() operations on the values; do arithmetic on the final results of the operations.

    Comment


      #3
      Hello johnnybegoode,

      Thanks for your post.

      With a defined group of indicators, on each OnBarUpdate() you could assign the indicators current values into an array and then use the Array.Min and Array.Max to determine the values of interest.

      This is more of a c# type question than a ninjascript question so I will provide links to internet sources to get you started, you may want to look for further tutorials on C# array.
      Create and loop over a string array. Access array Length and get elements at indexes.

      To get the Min/Max: https://www.dotnetperls.com/max


      Paul H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      148 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      5 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,283 views
      0 likes
      Last Post Leafcutter  
      Working...
      X