My goal is to only work with data between the hours of 9:30 and 10:30 EST and I don't want to look at the rest of the data. I found DateRange.efs by eSignal's Project Manager Jason K. and modified as shown below. I changed it to hours and minutes instead of days, months, and years. Only problem is the market opens at 9:30 and is not an even number (ie, 9:00, or 10:00, or 11:00 etc.) so I can get a half hour of data or one and a half hours.
Anyone have any ideas how to set this up so I only look at the first hour of the trading day?
Anyone have any ideas how to set this up so I only look at the first hour of the trading day?
PHP Code:
function preMain() {
setPriceStudy(true);
setStudyTitle("Date Range");
setShowCursorLabel(false);
var fp1 = new FunctionParameter("startH", FunctionParameter.NUMBER);
fp1.setName("Start Hour");
for (var i = 1; i <=24; ++i) {
fp1.addOption(i);
}
var fp2 = new FunctionParameter("startM", FunctionParameter.NUMBER);
fp2.setName("Start Minute");
for (var i = 1; i <=60; ++i) {
fp2.addOption(i);
}
fp2.setDefault(0);
var fp3 = new FunctionParameter("endH", FunctionParameter.NUMBER);
fp3.setName("End Hour");
for (var i = .5; i <=24; ++i) {
fp3.addOption(i);
}
fp3.setDefault(24);
var fp4 = new FunctionParameter("endM", FunctionParameter.NUMBER);
fp4.setName("End Minute");
for (var i = 1; i <=60; ++i) {
fp4.addOption(i);
}
fp4.setDefault(60);
}
function main(startH, startM, endH, endM) {
var barHour = getHour(0);
var barMinute = getMinute(0);
if (barMinute < startM || barMinute > endM) return;
if (barHour < startH || barHour > endH) return;
// Insert code for back testing here
setBarBgColor(Color.grey);
return;
}
Comment