Hello!
I'm trying to draw rectangle that starts at certain position (if condition) and extends to the end of the day. I want it to have not only on current day (then it would be easier becauase I could use barcount function) but also for historical charts.
I tried to do sth like this (if there is a gap-up, then draw a rectangle):
bi = BarIndex();
FVB = FirstVisibleValue(bi);
LVB = LastVisibleValue(bi);
firstBarDay=DateNum()!=Ref(DateNum(),-1); //changing date
//Yesterday's High (for gap)
TimeFrameSet(inDaily);
PrevHighD=Ref(H,-1);
TodayOpenD=O;
TimeFrameRestore();
PrevH=TimeFrameExpand(PrevHighD,inDaily,expandFirst);
TodayO=TimeFrameExpand(TodayOpenD,inDaily,expandFirst);
GapUp=IIf(TodayO > PrevH AND firstBarDay==1, 1, 0);
GfxSetZOrder(-5);
GfxSetCoordsMode(1);
GfxSetBkMode(1);
GfxSelectPen(ColorRGB( 50, 100, 150), 1, 0);
GfxSelectSolidBrush( ColorRGB( 50, 100, 150) );
for (i=FVB-100;i<LVB;i++)
{
if (GapUp[i]==1)
{
GfxRectangle(i, TodayO[i], i+70, PrevH[i]); // i+70 is a problem!!!
}
}
It draws a rectangle but the width (in bars) is fixed (currently set to 70 for 5min). It looks like this below:
On different instruments (or time-frames) there is different number of bars every day.
So for historical charts it should extend a rectangle to the end of the day and for current day it should draw a rectangle to the last bar.
Any suggestions, please...