Help with create lag variable

 

Hello,

I want to create variable up_0 and up_1 where up_1 is lag 1 period of up_0.

I can do it like that

if ( High[i] > High[i+1] ) {up_0[i]=1;}
if ( High[i+1] > High[i+2] ) {up_1[i]=1;}

But I really want to apply the below approach.

up_1(i)=up_0(i+1)

Could you please tell me how to do that?

Thank you very much.

SCFX

 
scfx:

Hello,

...

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

 
scfx: But I really want to apply the below approach.
up_1(i)=up_0(i+1)
Could you please tell me how to do that?
if ( High[i] > High[i+1] ) {up_0[i]=1;}
//if ( High[i+1] > High[i+2] ) {up_1[i]=1;}
up_1[i]=up_0[i+1]; // What's the problem?
 
WHRoeder:
Thank you for your reply, I cannot make up_0[i] but just up_0, so that second row is not working

if ( High[i] > High[i+1] ) {up_0=1;}
//if ( High[i+1] > High[i+2] ) {up_1[i]=1;}
up_1[i]=up_0[i+1];

//In this case, I cannot make up_0[i] but just up_0, so that second row is not working
 
scfx: I cannot make up_0[i] but just up_0,
if ( High[i] > High[i+1] ) {up_0[i]=1;}
That's not what you original posted. Either you have to have the previous value in an array or you must calculate it with your i+1 i+2
 
WHRoeder:
That's not what you original posted. Either you have to have the previous value in an array or you must calculate it with your i+1 i+2


You are right. I don't have it in array and I guess the question is that how can I turn/make it an array.

Reason: