Izak, just to make sure I'm using all the same variables, tell me what time template you are using (Chart Options-->Time Templates).
Announcement
Collapse
No announcement yet.
daily high
Collapse
X
-
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
-
Hello Izak,
That's strange. I didn't know that was possible. Post an image of your chart or tell me what it says in the upper left corner of the chart.
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
-
Hello Izak,
Well I didn't get the result I was hoping for at the open this morning. I think the problem is that, at the instance we're trying to repopulate the arrays, the new daily bar doesn't exist yet. When the routine completes, the most recent daily bar is still yesterdays. If you set the time trigger to 1031 or 1035, I think you might get the result you want. Try this with your formula at the open tomorrow.
However, to approach this from another angle, there may be another solution all together. It seems to me that when the new session starts you just want to insert a new array element at [0] with the new daily high, low and close and move everything else down 1 element in the array. Correct? Do you want to update the [0] element of the arrays throughout the day with the most current daily bar info? If so, try the modified formula below. This detects when the first tick of the first bar of the new days occurs and inserts a new element to the front of your arrays. Then at the open (or BARSTATE_NEWBAR) of each bar intra-day, the [0] element is updated with the current day's daily bar high, low and close. Let me know if this is a workable solution for you.
PHP Code:var flg = Text.ONTOP|Text.BOLD|Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.FRAME;
var t1=false;
var t2=false;
var tckrD = null;
function preMain(){
setPriceStudy(true);
setStudyTitle("Daily High b");
setShowCursorLabel(false);
setShowTitleParameters(false);
}
var DR=new Array();
var DH=new Array();
var DL=new Array();
var CL=new Array();
var TAR=new Array();
function get1(){
for (var i=0;i<20;i++) {
DH[i] = high(-i,tckrD);
DL[i] = low(-i,tckrD);
CL[i] = close(-i,tckrD);
DR[i] = DH[i]-DL[i]
}
for (var i=0;i<20;i++) drawTextPixel(250,(20*i)+15,i+" "+DH[i].toFixed(2)+" "+DL[i].toFixed(2)+" "+CL[i].toFixed(2)+" "+DR[i].toFixed(2),null,null,flg,null,12,"T1"+i,300);
//debugPrintln("get1 executed");
}
function get2(){ // not used
var DR=new Array();
var DH=new Array();
var DL=new Array();
var CL=new Array();
var TAR=new Array();
//var AvgDR=0;
//var kbar=0;
//var mxR=-1e10;
//var mnR=1e10;
for (i=0;i<20;i++) {
DH[i] = high(-i,tckrD);
DL[i] = low(-i,tckrD);
CL[i] = close(-i,tckrD);
DR[i] = DH[i]-DL[i]
}
for (var i=0;i<20;i++) drawTextPixel(555,(20*i)+15,i+" "+DH[i].toFixed(2)+" "+DL[i].toFixed(2)+" "+CL[i].toFixed(2)+" "+DR[i].toFixed(2),null,null,flg,null,12,"T2"+i,300);
//debugPrintln("get2 executed");
}
function draw2() {
for (var i=0;i<20;i++) drawTextPixel(555,(20*i)+15,i+" "+DH[i].toFixed(2)+" "+DL[i].toFixed(2)+" "+CL[i].toFixed(2)+" "+DR[i].toFixed(2),null,null,flg,null,12,"T2"+i,300);
return;
}
function main(){
var nState = getBarState();
if (tckrD == null) {tckrD = getSymbol()+",D"; /*debugPrintln(tckrD);*/}
if (nState == BARSTATE_ALLBARS) {t1=false;t2=false;return;}
if (getCurrentBarIndex()==0){
if(!t1) {get1(); t1=true;}
//if (getBarState() != BARSTATE_NEWBAR && getHour()*100+getMinute()>=1031 && !t2) { // should be first tick after the open.
//var t=new Date();
//if (t.getHours()*100+t.getMinutes()>=1030 && !t2) {get2();t2=true;}
//if (getHour()*100+getMinute()>=630 && !t2) {get2();t2=true;}
// get2();
// t2=true;
//}
var bNewDay = false;
if (t2 == false) {
var t = new Date();
var d = getDay(0);
if (t.getDate() == d) bNewDay = true;
}
if (getDay(0) != getDay(-1) && nState == BARSTATE_NEWBAR) {
bNewDay = true;
t2 = false;
}
if (bNewDay == true && t2 == false) {
DH.pop(); // removes last element
DH.unshift(high(0,tckrD)); // inserts new element at [0]
DL.pop();
DL.unshift(low(0,tckrD));
CL.pop();
CL.unshift(close(0,tckrD));
DR.pop();
DR.unshift(DH[0]-DL[0]);
draw2();
debugPrintln("arrays updated");
t2 = true;
}
if (t2 == true && nState == BARSTATE_NEWBAR) {
DH[0] = high(0,tckrD);
DL[0] = low(0,tckrD);
CL[0] = close(0,tckrD);
DR[0] = DH[0]-DL[0];
draw2();
}
}
return;
}
Attached FilesJason 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
-
Hi Jason,
Thank you for all your help.
I have also tried what you offered i.e. run it at 10:31 & 10:35 etc. but it does not work also. I know that, it is possible to shift the array within the code, and this is what I am currently doing in my code, but this does not answer my question.
It seems totally absurd to me why we can not get the new DH[0] that way. I have tried to run the code without success when a Daily chart is also open besides the intraday chart (in case the Data Manager might not be updating the Daily figures when only an intraday chart is open) . We are either missing something or it is a bug.
again thanks a lot,
Izak
Comment
-
Hello Izak,
The formula I provided for you in my last post should do the trick for you. The problem I think is a timing issue, not a bug. Another thing you could do vs. accessing the data from the daily interval is to set up two global variables for the daily high and low. On each trade you would do something like, nDH = Math.max(high(), nDH) and then update DH[0] = nDH.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
Comment