Hi Guys
How to draw a horizontal shade between price close on Friday at 8 am and Open on Monday 10 am. This is Au time that my charts are in.
Any help would be great
maybe you can draw a Rectangle ?
There you go:
DEFPARAM DrawOnLastBarOnly = true
IF OpenTime = 080000 AND OpenDayOfWeek = 5 THEN
Bar8 = BarIndex
cl = close
Bar10 = Bar8
op = cl
ENDIF
IF OpenTime = 100000 AND OpenDayOfWeek = 1 THEN
Bar10 = BarIndex
op = open
ENDIF
DrawSegment(Bar8,cl,bar10,op)
RETURN
I added it to the chart but it did not draw anything?
Hi,
Not knowing what TF you used and how much history you loaded, these are hypothetical items to check, just in case:
– is it a timeframe compatible, meaning having candles open/close timing compatible with these coded times? (so… not x ticks, not daily, etc…)
– and if yes, are there enough units loaded to have the first point last friday at 8 part of available history? (for example, if 1mn TF, having 10000 rather than only 1000 units)
(PS: from moderation point of view, moving the topic from French forum to English forum in a few minutes, thanks)
Thanks for the code. I am using it in 5m chart with 10K bars loaded, so its definately not working. I am sure something minor is missing
Another possibility comes to mind: when you say “added to the chart”, do you mean inside the price window, or does it appear as a separate window at the bottom of the chart?
Yes off course price window
Ok i could not see it due to colour its drawing a line. How can I have it draw a rectange that extends to current price just like line?
JSParticipant
Senior
DEFPARAM DrawOnLastBarOnly = true
IF OpenTime = 080000 AND OpenDayOfWeek = 5 THEN
Bar8 = BarIndex
cl = close
ENDIF
IF OpenTime = 100000 AND OpenDayOfWeek = 1 THEN
Bar10 = BarIndex
op = open
ENDIF
Drawrectangle(Bar8,cl,bar10,op)
RETURN
Horizontal Rectangle, like pivot lines. ITs because, if you load this indicator in 5m or 1 m chart, you cannot see it without scrolling all the way to Monday. thanks
Hi Roberto
Is it possible to have hortizontal rectange accross rather than a segment?
thanks
PJ
This is a modified version of https://www.prorealcode.com/topic/friday-close-and-monday-open-gap/#post-211257:
DEFPARAM DrawOnLastBarOnly = true
IF OpenTime = 080000 AND OpenDayOfWeek = 5 THEN
Bar8p = Bar8
Bar8 = BarIndex
cl = close
ENDIF
IF OpenTime = 100000 AND OpenDayOfWeek = 1 THEN
Bar10 = BarIndex
op = open
ENDIF
Drawrectangle(Bar8p,cl,bar10,op) coloured("Red",20) bordercolor("Cyan") style(line,2)
RETURN
20 is the transparency attribute (0=invisible, 255=max.visibility).
2 is the line thickness (1 to 5).
Thanks but it looks bit odd in the chart. It seems to be connecting all open and close of new week. I was expecting it to have individual shades for DClose of Saturday (AEST) and DOpen (Monday). Is it not possible to have a line that extend to current price area?
This version gets rid of some mess (when uncommenting line 1):
//DEFPARAM DrawOnLastBarOnly = true
IF OpenTime = 080000 AND OpenDayOfWeek = 5 THEN
Bar8 = BarIndex
cl = close
ENDIF
IF OpenTime = 100000 AND OpenDayOfWeek = 1 THEN
Bar10 = BarIndex
op = open
ENDIF
IF Bar10 > Bar8 THEN
Drawrectangle(Bar8,cl,bar10,op) coloured("Red",20) bordercolor("Cyan") style(line,2)
ENDIF
RETURN
Of course you will have to change those times, as they are CET (EU) times.
DCLOSE, DOPEN, etc… match the broker’s day start (which is now at 01:00, not 00:00). This means that 00:00 are still visible, but with OpenDayOfWeek they belong to the previous day, despite the date being correct.