Update
The code works well for daily, hourly but seems not to work for weekly TF (executed from 15 min TF as default TF)
Do not understand why… Prorealcode is full of mysteries
seems not to work for weekly TF executed from 15 min TF
but works if executed from 1 hour
So I guess from 15 min to weekly, we start to get some visible precision/rounding problems…
I consider the problem closed
I just tweaked my previous code a little bit and this code works for me.
timeframe(weekly)
if barindex = 1 then
xOpen = open
endif
if barindex > 1 then
xClose=(open+high+low+close)/4
xOpen =( xOpen[1] + xClose[1] )/ 2
endif
timeframe(default)
RETURN xOpen AS "xOPen" , xClose as "xClose"
BTW, this works also for daily TF , just replace “weekly” by “daily” . We have to calculate the HA values starting from barindex 1 on in the higher TF, otherwise we dont have valid values of xOpen available !
@jerome888 after all I found your code in the first message of the thread was almost perfect, just needed to initialize xOpen like this:
timeframe(daily)
if barindex = 1 then
xOpen = open
endif
Hi pableitor
Thank you.
I have tried the code, seems not to work on my side (I come back to the first problem x close is correct but not xopen).
I will have to recheck again tomorrow but I am sure at 90% that it still contains a problem…
Yes your above code works quite well.
– From 1 h TF, no problem to get data of 1 week TF
– From 15 min i get problem for getting 1 week TF data but I assume that is linked to the limited history (in 15min, with PRT complete version, I can display (so load I guess) only 233 units so 10 working days)
So topic solved Thanks a lot for your support pableitor.
(I will probably create same kind of topics for SMA and RSI since I fail as well to get the right values…)