iLowest

Returns the index of the bar with the lowest value over a specified range.

Syntax

iLowest(symbol: string, timeFrame: number, type: number, count: number, index: number): number

Parameters

  • symbol: The symbol to get data for

  • timeFrame: The timeframe of the data (in minutes)

  • type: The price type to compare (0=OPEN, 1=HIGH, 2=LOW, 3=CLOSE, 4=VOLUME)

  • count: Number of bars to search through

  • index: The starting bar index (0 is current/last bar, 1 is previous bar, etc.)

Return Value

Returns a number representing the index of the bar with the lowest value. Returns -1 if no valid bar is found.

Description

The iLowest method searches for the bar with the lowest value of the specified price type (open, high, low, close, or volume) within a range of bars. The search starts from the specified index and looks back for the specified number of bars. The method is useful for finding local minima and implementing various technical analysis strategies.

Example

// Find lowest low price in last 10 bars
const lowestIndex = this.api.iLowest("EURUSD", 60, 2, 10, 0);
if (lowestIndex !== -1) {
  const lowestPrice = this.api.iLow("EURUSD", 60, lowestIndex);
  console.log(`Lowest price: ${lowestPrice} at index ${lowestIndex}`);
}

// Find lowest close in last 20 bars
const lowestCloseIndex = this.api.iLowest("EURUSD", 60, 3, 20, 0);

// Find lowest volume in last 5 bars
const lowestVolumeIndex = this.api.iLowest("EURUSD", 60, 4, 5, 0);

// Check if current bar is lowest in last 50 bars
const isNewLow = this.api.iLowest("EURUSD", 60, 2, 50, 0) === 0;

// Find lowest low starting from a specific bar
const startIndex = 10;
const lookback = 5;
const lowIndex = this.api.iLowest("EURUSD", 60, 2, lookback, startIndex);

// Get lowest price values for different types
const types = [0, 1, 2, 3]; // OPEN, HIGH, LOW, CLOSE
const lowestValues = types.map((type) => {
  const idx = this.api.iLowest("EURUSD", 60, type, 10, 0);
  return idx !== -1 ? this.api.iLow("EURUSD", 60, idx) : null;
});

// Find price channel
const highestHigh = this.api.iHigh(
  "EURUSD",
  60,
  this.api.iHighest("EURUSD", 60, 1, 20, 0)
);
const lowestLow = this.api.iLow(
  "EURUSD",
  60,
  this.api.iLowest("EURUSD", 60, 2, 20, 0)
);
const channelHeight = highestHigh - lowestLow;

Last updated