Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MIN and MAX functions

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

    MIN and MAX functions

    I'm trying to get the minimum and maximum of two values in the script, but it seems like MIN and MAX function don't work properly or are the wrong functions. Does anyone have a resolution?

    Here is the part of code I cant get to work:
    else if (State == State.DataLoaded)
    {
    bollinger = Bollinger(2, 20);
    }​


    protected override void OnBarUpdate()
    {
    if(CurrentBar < 2) return;
    double upperValue = bollinger.Upper[1];
    double lowerValue = bollinger.Lower[1];

    double _HigherBand = MAX(upperValue,2)[0];// I need to identify the highest BB Upper band of the last two candles from previous close (close[1] and close[2]
    double _LowerBand= MIN(lowerValue,2)[0];
    }​​

    #2
    Hello Ray11,

    Thanks for your post.

    MIN() could be used to get the lowest value over a specific period. MAX() could be used to get the highest value over a specific period.

    Calling bollinger.Upper[1] and bollinger.Lower[1] returns a double value.

    MIN() and MAX() requires that you pass in a Series<double> value and an int argument to specify the period.

    MIN(int period)
    MIN(ISeries<double> input, int period)


    MAX(int period)
    MAX(ISeries<double> input, int period)
    ​​

    See the help guide documentation below for information about MIN() and MAX() as well as sample code.
    MIN: https://ninjatrader.com/support/help...inimum_min.htm
    MAX: https://ninjatrader.com/support/help...aximum_max.htm

    Please let me know if I may assist you further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    84 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    47 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    29 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    66 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X