Hi,
I tried to create an indicator to show a yellow rectangle around some hours of the new york session.
i did some copy pasting from other codes, because i am new to coding. see the attatched code.
My problem, the code works fine for ES/MES , indexes.
But i want is also to work for currancypairs, like EURUSD, etc.
Can anyone tell me why it is not working?
starttime = 140000
endtime = 170000
if time = starttime then
startbar = barindex
endif
if time = endtime then
endbar = barindex
endif
if time >= starttime and time <= endtime then
if high > hh then
hh = high
endif
if low < ll or ll = 0 then
ll = low
endif
endif
hh = round(hh)
ll = round(ll)
if intradaybarindex = 0 then
hh = 0
ll = 0
endif
if time > endtime then
DrawRectangle(startbar,hh,endbar,ll) coloured("Yellow",25) BorderColor("Yellow",25)
endif
return
Hi,
delete both lines with “round”: lines 21 and 22
Using “round()” brings you to the closest integer. On an index quoting in thousands, rounding it doesn’t change its value a lot, but on a currency where pips are in decimals… for example EURUSD, an hh at 1.09613 when rounded would become = 1 and rounding ll = 1.09314 would make it = 1 too… so that’s a flat rectangle located at 1, which is why you couln’t see anything.
Code will work without these 2 lines.
Thanks a lot, you are my hero! 😉
Can someone help me with the following please: is it possible to see the rectancle during the session?
Now you only see the rectangle in hindsight.
I know it has to do with “if time > endtime then” but i tried different this, but no results….
Thanks in advance!