I'm trying to get yesterday's OHLC for symbol es #f...either there are no data points or the dataa points are wrong when I try to use the formulas in the OHLC file...any help would be greatly appreciated...
Announcement
Collapse
No announcement yet.
Yesterday's OHLC
Collapse
This topic is closed.
X
X
-
Hello Wareal,
Here's a code example that should do what you need. First, you'll need to download getPrevDaysOHLC.efs and save it to eSignal\Formulas\OHLC\. This is a utility formula that you can use within your custom formula using callFunction(). The input parameters that getPrevDaysOHLC.efs requires are:
Price Source, Offset, Number of Days
In your case you need to pass 0 for offset and 1 for the numbers of days of data. The offset seems counter intuitive and I may re-code the logic for that. But for now think of the offset as a number that is relative to yesterday's bar where yesterday is 0.
YesterdayOHLC.efs
PHP Code:function preMain() {
setPriceStudy(true);
setStudyTitle("Yesterday's OHLC");
setCursorLabelName("Prev Open", 0);
setCursorLabelName("Prev High", 1);
setCursorLabelName("Prev Low", 2);
setCursorLabelName("Prev Close", 3);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarFgColor(Color.green, 2);
setDefaultBarFgColor(Color.black, 3);
}
var prevO = null;
var prevH = null;
var prevL = null;
var prevC = null;
function main() {
if (getDay() != getDay(-1)) {
prevO = callFunction("/OHLC/getPrevDaysOHLC.efs", "main", "Open", 0, 1);
prevH = callFunction("/OHLC/getPrevDaysOHLC.efs", "main", "High", 0, 1);
prevL = callFunction("/OHLC/getPrevDaysOHLC.efs", "main", "Low", 0, 1);
prevC = callFunction("/OHLC/getPrevDaysOHLC.efs", "main", "Close", 0, 1);
}
if (prevO == null || prevH == null || prevL == null || prevC == null) return;
return new Array(prevO[0], prevH[0], prevL[0], prevC[0]);
}
Jason K.
Project Manager
eSignal - an Interactive Data company
EFS KnowledgeBase
JavaScript for EFS Video Series
EFS Beginner Tutorial Series
EFS Glossary
Custom EFS Development Policy
New User Orientation
Comment