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.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,404 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    95 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    8 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    159 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    8 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X