Help with formula

I have problem with the code below:
hOpen = (Ref(hOpen, -1)+Ref(hClose, -1))/2;
hHigh = Max(hOpen,Max(C,hClose));
hLow = Min(hOpen, Min( Low, hClose ) );
hClose = (hOpen + High + Low + 2*Close)/5;

I don´t get the correct result.
I think it is the first row that is the problem, that "hOpen" uses yesterdays "hOpen".

Is there someone out there that can help me?

Best regards,
Leif Axelsson

@AsaLeffe, if you think the first line is a problem, what can you do to change it...

It could also be that your first line references hClose, which is not yet defined.

Additionally, hClose references hOpen.

Looks like a circular reference to me.

Take a look at your calculation and see if you can re-work it, to not include the circular reference.

Another option might be to initialize some values before you start doing your calculations.

Good Luck