English

## Help with create lag variable

 82 scfx 2014.02.14 18:27   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
 13128 WHRoeder 2014.02.14 20:21 #   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?```
 82 scfx 2014.02.14 20:46 #   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```
 13128 WHRoeder 2014.02.14 21:20 #   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