dasio: No it was generated when the price was already formed. I'm not a coder so i don't know where is the problem. I try only to help ^^.
It seems that the error with different values is located
Try out this version. Here is a comparison of a regular heiken ashi and an offline chart generated by this indicator. As far as I see they are identical now but please let me know if you find some problems