HighestBar()

View as Markdown

Definition

Returns the number of bars ago the highest price value occurred within the specified look-back period.

Method Return Value

An int value representing a value of bars ago.

Syntax

HighestBar(ISeries\<double\> series, int period)

Parameters

ParameterDescription
periodThe number of bars to include in the calculation
seriesAny Series<double> type object such as an indicator, Close, High, Low, etc…

Examples

1protected override void OnBarUpdate()
2{
3 // store the highest bars ago value
4 int highestBarsAgo = HighestBar(**High, Bars.BarsSinceNewTradingDay);
5
6 //evaluate high price from highest bars ago value
7 double highestPrice = High[highestBarsAgo];
8
9 //Printed result: Highest price of the session: 2095.5 - occurred 24 bars ago
10 Print(string.Format("Highest price of the session: {0} - occurred {1} bars ago", highestPrice, highestBarsAgo));
11}