File Name: getPrevMonthsOHLC.efs
Description:
Utility formula that returns a single value or an array of values for previous months’ Monthly open, high, low and close data.
Formula Parameters:
sPriceSource: Default is Close (valid inputs: Open, High, Low or Close).
nOffset: Default is –1
nNumMonths: Default is 1
Notes:
This formula is intended to be used by other custom formulas to access previous months' monthly values that can then be used with formulas that need to plot the monthly data on intra-day, daily or weekly intervals. Save this formula to /eSignal/Formulas/OHLC/ and use the callFunction() function from within your custom formula. Download PrevMonthsHHLL.efs to see a working example.
The example formula will return the previous two Months' highest high and lowest low.
Download File:
getPrevMonthsOHLC.efs
EFS Code:
Description:
Utility formula that returns a single value or an array of values for previous months’ Monthly open, high, low and close data.
Formula Parameters:
sPriceSource: Default is Close (valid inputs: Open, High, Low or Close).
nOffset: Default is –1
nNumMonths: Default is 1
Notes:
This formula is intended to be used by other custom formulas to access previous months' monthly values that can then be used with formulas that need to plot the monthly data on intra-day, daily or weekly intervals. Save this formula to /eSignal/Formulas/OHLC/ and use the callFunction() function from within your custom formula. Download PrevMonthsHHLL.efs to see a working example.
The example formula will return the previous two Months' highest high and lowest low.
Download File:
getPrevMonthsOHLC.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/getMonthlyOHLC.efs", "main", "High", -2, 2);
if (vData == null) return;
return vData;
**/
var vSymbol;
var vInterval;
function main(sPriceSource, nOffset, nNumMonths) {
if(sPriceSource == null) return;
if (nOffset == null) {
nOffset = -1;
} else {
nOffset = (Math.abs(nOffset) * -1);
}
if (nNumMonths == null) {
nNumMonths = 1;
} else {
nNumMonths = Math.abs(nNumMonths);
}
var vValue = null;
var vBarTime;
var vAbsTime;
var vIndex;
var nState = getBarState();
if(nState == BARSTATE_ALLBARS) {
vSymbol = getSymbol();
vInterval = getInterval();
vSymbol += ",M";
}
if(vInterval == null) return;
if(vInterval == "M") return;
vBarTime = getValue("time");
var vTime = new Date();
if(vBarTime != null) {
if (vTime.getYear() == vBarTime.getYear()) {
vIndex = ((vTime.getMonth()+1 - vBarTime.getMonth()+1) * -1)+2;
} else {
vIndex = (((vTime.getMonth()+1 + ((vTime.getYear() - vBarTime.getYear()) * 12)) - vBarTime.getMonth()+1) * -1)+2;
}
if (vIndex != null) {
vValue = getValueAbsolute(sPriceSource, (vIndex + nOffset), nNumMonths, vSymbol);
if (vValue == null) return null;
}
}
return vValue;
}