Thanks to crolakstrading for spotting an issue with my ‘OHLC Y Q M W D H4 H1 Last Bar’ indicator when displaying the H4 OHLC lines.
I have fixed the code and attached the updated version here. I will post a comment on the library post directing people to here.
Hi @vonasi,
Sorry to come back to this all over again. it has the same issue on the weekly. if on the weekly chart that doesn’t plot the lines only on the weekly.. i really try to fix it but impossible for me to do!! I think everything else is perfect!
Yes – weeks in PRT can be a challenge because there is no instruction for weeks such as OPENWEEK or WEEK so we can only know that a new week has started if we compare OPENDAYOFWEEK to OPENDAYOFWEEK[1] and it is lower. On a weekly chart every bar starts with an OPENDAYOFWEEK value of zero so it never identifies that a new week has started.
I have not come up with a solution for this other than perhaps trying to add some time frame recognition code…. I’ll have to have a think about it.
ahh ok, thanks for the clarification! weekly lines are shown on Daily, 4h, and 1hr perfectly. it’s just only on the weekly!
I notice that it can also get confused and sometimes draw weekly lines on monthly charts due to the fact that have no way apart from checking the day of the week to know if a week has started or not. I really have not got a solution for it at the moment.
I think you can tell if a new week has started when OpenDay > OpenDay[1] (you might want to use DAY, instead) OR when it’s lower but Month <> Month[1] (not tested, just guessing).
DAY or OPENDAY just returns a number from 1 to 31 for the day of the month so that being higher tells us only that it is a new day unless it is the last day of the month. If it is lower it tells us it is a start of a month but we want to know if it is a start of a week!
OPENDAYOFWEEK < OPENDAYOFWEEK[1] is what I use in the code but on a weekly chart every bar has the same value. Also on a monthly chart random bars will meet this condition too.