getFirstBarIndexOfDay()

eSignal EFS

getFirstBarIndexOfDay()

 

getFirstBarIndexOfDay( Date,  [symbol]  )

 

  • Date:  A valid Date object (using "time" or "rawtime").
  • symbol: Optional parameter. The function will use the chart symbol and interval if no specified. Otherwise you may specify another symbol as well as na interval (see example 2).

 

Gets the absolute value index to the first bar of the given date.

 

Example 1:

 

var vTime = getValue("Time");

 

if (vTime != null) {

var vFirstIndex = getFirstBarIndexOfDay( vTime );

if (vFirstIndex != null) {

  vTodaysOpen = getValueAbsolute( "open", vFirstIndex );

}

}

 

Example 2:

 

Gets the absolute value index to the first bar of the given date for the specified symbol and interval. This is most commonly used to get the open price for the current chart symbol based on the daily bar from an intraday or tick chart.

 

var vTodaysOpen = null;

 

function main() {

var vTime = getValue("Time");

var vFirstIndex = getFirstBarIndexOfDay( vTime, getSymbol() + ",D");

if ( vFirstIndex != null && getDay(0) != getDay(-1) ) {

  debugPrintln( getCurrentBarIndex() + " " + vFirstIndex );

  vTodaysOpen = getValueAbsolute( "open", vFirstIndex, getSymbol() + ",D" );

}

 

return vTodaysOpen;

}