I did the neophyte task of searching and found this gem - Almost exactly what I wanted. My programming level is - I know enough to be dangerous, but I'm getting slightly less so over time, much too slightly.
Anyway, I was wondering if you could add another feature to this elegant code you wrote a few years ago to include - the opening value at a particular time. In my case, I'll be setting it to 9:30.
Thank You Once Again,
Glenn Swiatek
/************************************************** *******
Alexis C. Montenegro © June 2005
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var fpArray = new Array();
function preMain() {
setPriceStudy(true);
setStudyTitle("HiLo_firstXminutes");
setCursorLabelName("High", 0);
setCursorLabelName("Low", 1);
setPlotType(PLOTTYPE_FLATLINES,0);
setPlotType(PLOTTYPE_FLATLINES,1);
setDefaultBarFgColor(Color.blue,0);
setDefaultBarFgColor(Color.red,1);
var x=0;
fpArray[x] = new FunctionParameter("xStart", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Start Time");
setLowerLimit(0);
setDefault(930);
}
fpArray[x] = new FunctionParameter("xEnd", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("End Time");
setLowerLimit(0);
setDefault(1030);
}
fpArray[x] = new FunctionParameter("xInterval", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Ext Interval Used");
setLowerLimit(1);
setDefault(5);
}
fpArray[x] = new FunctionParameter("xDisplay", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Display");
addOption("Show");
addOption("Hide");
setDefault("Show");
}
}
var bInit = false;
var xRange = null;
function main(xStart,xEnd,xInterval,xDisplay) {
if(bInit==false){
xRange = efsInternal("calcOR",xStart,xEnd,xDisplay,inv(xInt erval));
bInit=true;
}
return new Array(getSeries(xRange,0),getSeries(xRange,1));
}
var vFlag = true;
var vFlag2 = true
var vHigh = null;
var vLow = null;
var vClose = null;
var vDay1 = null;
var vDay2 = null;
function calcOR(start,end,display,source){
if (getBarState() == BARSTATE_NEWBAR) {
if (vDay1 == null) {
vDay2 = getDay(0);
} else {
vDay2 = vDay1;
}
vDay1 = getDay(0);
if (vDay1 != vDay2) {
vHigh = null;
vLow = null;
vFlag = true;
vFlag2 = false;
}
var vHour1 = (getHour()*100)+getMinute();
if(vHour1 >= start){
vFlag2=true;
}
var vHour = (getHour()*100)+getMinute();
if (vHour >= end) {
vFlag = false;
vFlag2=false;
}
}
if (vFlag == true&&vFlag2==true) {
if (vHigh == null) {
vHigh = high(0);
}
if (vLow == null) {
vLow = low(0);
}
vHigh = Math.max(high(0), vHigh);
vLow = Math.min(low(0), vLow);
}
if(display=="Hide"){
if(vFlag==false&&vHigh!=null&&vLow!=null){
var vHigh2 = vHigh;
var vLow2 = vLow;
}
}else if(display=="Show"){
var vHigh2 = vHigh;
var vLow2 = vLow;
}
return new Array(vHigh2,vLow2);
}
Anyway, I was wondering if you could add another feature to this elegant code you wrote a few years ago to include - the opening value at a particular time. In my case, I'll be setting it to 9:30.
Thank You Once Again,
Glenn Swiatek
/************************************************** *******
Alexis C. Montenegro © June 2005
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var fpArray = new Array();
function preMain() {
setPriceStudy(true);
setStudyTitle("HiLo_firstXminutes");
setCursorLabelName("High", 0);
setCursorLabelName("Low", 1);
setPlotType(PLOTTYPE_FLATLINES,0);
setPlotType(PLOTTYPE_FLATLINES,1);
setDefaultBarFgColor(Color.blue,0);
setDefaultBarFgColor(Color.red,1);
var x=0;
fpArray[x] = new FunctionParameter("xStart", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Start Time");
setLowerLimit(0);
setDefault(930);
}
fpArray[x] = new FunctionParameter("xEnd", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("End Time");
setLowerLimit(0);
setDefault(1030);
}
fpArray[x] = new FunctionParameter("xInterval", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Ext Interval Used");
setLowerLimit(1);
setDefault(5);
}
fpArray[x] = new FunctionParameter("xDisplay", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Display");
addOption("Show");
addOption("Hide");
setDefault("Show");
}
}
var bInit = false;
var xRange = null;
function main(xStart,xEnd,xInterval,xDisplay) {
if(bInit==false){
xRange = efsInternal("calcOR",xStart,xEnd,xDisplay,inv(xInt erval));
bInit=true;
}
return new Array(getSeries(xRange,0),getSeries(xRange,1));
}
var vFlag = true;
var vFlag2 = true
var vHigh = null;
var vLow = null;
var vClose = null;
var vDay1 = null;
var vDay2 = null;
function calcOR(start,end,display,source){
if (getBarState() == BARSTATE_NEWBAR) {
if (vDay1 == null) {
vDay2 = getDay(0);
} else {
vDay2 = vDay1;
}
vDay1 = getDay(0);
if (vDay1 != vDay2) {
vHigh = null;
vLow = null;
vFlag = true;
vFlag2 = false;
}
var vHour1 = (getHour()*100)+getMinute();
if(vHour1 >= start){
vFlag2=true;
}
var vHour = (getHour()*100)+getMinute();
if (vHour >= end) {
vFlag = false;
vFlag2=false;
}
}
if (vFlag == true&&vFlag2==true) {
if (vHigh == null) {
vHigh = high(0);
}
if (vLow == null) {
vLow = low(0);
}
vHigh = Math.max(high(0), vHigh);
vLow = Math.min(low(0), vLow);
}
if(display=="Hide"){
if(vFlag==false&&vHigh!=null&&vLow!=null){
var vHigh2 = vHigh;
var vLow2 = vLow;
}
}else if(display=="Show"){
var vHigh2 = vHigh;
var vLow2 = vLow;
}
return new Array(vHigh2,vLow2);
}