File Name: getPrevWeeksOHLC.efs
Description:
Utility formula that returns a single value or an array of values for previous weeks’ Weekly open, high, low and close data.
Formula Parameters:
sPriceSource: Default is Close (valid inputs: Open, High, Low or Close).
nOffset: Default is –1
nNumWeeks: Default is 1
Notes:
This formula is intended to be used by other custom formulas to access previous weeks' weekly values that can then be used with formulas that need to plot the weekly data on intra-day or daily intervals. Save this formula to /eSignal/Formulas/OHLC/ and use the callFunction() function from within your custom formula. Download PrevWeeksHHLL.efs to see a working example.
The example formula will return the previous two weeks' highest high and lowest low.
Download File:
getPrevWeeksOHLC.efs
EFS Code:
Description:
Utility formula that returns a single value or an array of values for previous weeks’ Weekly open, high, low and close data.
Formula Parameters:
sPriceSource: Default is Close (valid inputs: Open, High, Low or Close).
nOffset: Default is –1
nNumWeeks: Default is 1
Notes:
This formula is intended to be used by other custom formulas to access previous weeks' weekly values that can then be used with formulas that need to plot the weekly data on intra-day or daily intervals. Save this formula to /eSignal/Formulas/OHLC/ and use the callFunction() function from within your custom formula. Download PrevWeeksHHLL.efs to see a working example.
The example formula will return the previous two weeks' highest high and lowest low.
Download File:
getPrevWeeksOHLC.efs
EFS Code:
PHP Code:
/*********************************
Provided By : eSignal. (c) Copyright 2003
*********************************/
function preMain() {
}
/**
sPriceSource will be "Open", "High", "Close", or "Low"
This formula is for callFunction() calls from an
external formula.
example:
var vData = callFunction("/OHLC/getWeeklyOHLC.efs", "main", "High", -2, 2);
if (vData == null) return;
return vData;
**/
var vSymbol;
var vInterval;
var msPerDay = 24*60*60*1000;
function main(sPriceSource, nOffset, nNumWeeks) {
if(sPriceSource == null) return;
if (nOffset == null) {
nOffset = -1;
} else {
nOffset = (Math.abs(nOffset) * -1);
}
if (nNumWeeks == null) {
nNumWeeks = 1;
} else {
nNumWeeks = Math.abs(nNumWeeks);
}
var vValue;
var vBarTime;
var vAbsTime;
var vIndex;
var nState = getBarState();
if(nState == BARSTATE_ALLBARS) {
vSymbol = getSymbol();
vInterval = getInterval();
vSymbol += ",W";
}
if(vInterval == null) return;
if(vInterval == "W" || vInterval == "M") return;
vBarTime = getValue("time");
if(vBarTime != null) {
var vTime = new Date();
vIndex = (Math.round(Math.round((vTime.getTime() - vBarTime.getTime()) / msPerDay) / 7) * -1);
if(vIndex != null) {
vValue = getValueAbsolute(sPriceSource, (vIndex + nOffset), nNumWeeks, vSymbol);
if (vValue == null) return;
}
}
return vValue;
}