| File Name: getMonthlyOHLC.efs
Description: Returns the Monthly OHLC data with the use of callFunction() and may be used with any interval less than monthly.
Formula Parameters: sPriceSource: No Default value. Pass "Open" /"High"/"Low"/"Close" to callFunction() Notes: Save this formula to /eSignal/Formulas/OHLC/ and use this formula through the callFunction() function from your custom formulas to get the current week's OHLC prices.
Code Example:
function main() { var vData = callFunction("/OHLC/getMonthlyOHLC.efs", "main", "High"); if (vData == null) return; return vData; }
Download File: getMonthlyOHLC.efs

EFS 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"); if (vData == null) return; return vData;**/var vSymbol;var vInterval;function main(sPriceSource) { if(sPriceSource == null) return; var vBar; 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) { vBar = getValueAbsolute(sPriceSource, vIndex, vSymbol); return vBar; } } return;} |
|