CKWParticipant
Veteran
Hi Nicholas,
Could you please advise what’s different for X by using DailyHigh and High in “Highest[BarIndex – lastWeekBarIndex](X)”?
I observed some weeks having different result but I couldn’t explain why?
Which parameter is correct? I tried it on 4hours time frame.
// calculate daily high/low
dailyHigh = DHigh(1)
dailyLow = DLow(1)
// calculate weekly high/low
If DayOfWeek < DayOfWeek[1] then
weeklyHigh = Highest[BarIndex - lastWeekBarIndex](dailyHigh)
// weeklyHigh = Highest[BarIndex - lastWeekBarIndex](High)
lastWeekBarIndex = BarIndex
ENDIF
Thanks
br,
khin wong
Hi,
to be sure, a screen capture of what was observed (what instrument and when) would help to answer, but without it, the only thing I can think of when reading this piece of code is:
if dailyhigh has been defined as Dhigh(1) (previous day) then
weeklyHigh = Highest[BarIndex - lastWeekBarIndex](dailyHigh)
would only include highs from day before lasttweekbarindex until previous day when searching the highest of this selection, but not today’s high.
weeklyHigh = Highest[BarIndex - lastWeekBarIndex](High)
would include all highs from lastweekbarindex until today when searching the highest (but not high from day before lastweekbarindex).
So not knowing if it matches what you observed, I can only guess it is possible the differences you saw occured when current day high read by code was higher than any high from lastweekbarindex until previous day, or when a high the day before lastweekbarindex was higher than any high between lastweekbarindex and current day.
CKWParticipant
Veteran
Hi Noobywan,
Thanks for your explanation. It seems by using Dailyhigh should be more realistic.
br,
CKW