Maximum (MAX)

View as Markdown

Description

Returns the highest value over the specified period.

Syntax

MAX(int period)

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

Returns default value

MAX(int period)[int barsAgo]

MAX(ISeries\<double\> input, int period)[int barsAgo]

Return Value

double; Accessing this method via an index value [int barsAgo] returns the indicator value of the referenced bar.

Parameters

ParameterDescription
inputIndicator source data (Series<T>)
periodNumber of bars used in the calculation

Examples

1// Prints the highest high value over the last 20 periods
2double value = MAX(High, 20)[0];
3Print("The current MAX value is " + value.ToString());
4
5// Note the above call with a barsAgo of 0 includes the current MAX of the input high series in the value. If we want to check for example for a break of this value, storing the last bar's MAX would be needed.
6double value = MAX(High, 20)[1];
7
8if (High[0] > value)
9 Draw.ArrowUp(this, CurrentBar.ToString(), true, 0, Low[0] - TickSize, Brushes.Blue);

Source Code

You can view this indicator method source code by selecting the menu New > NinjaScript Editor > Indicators within the NinjaTrader Control Center window.