Download MetaTrader 5
To add comments, please log in or register
Add the thread to Favorites. Track the changes even faster!
Harry
267
Harry 2014.02.14 17: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

Alain Verleyen
Moderator
28518
Alain Verleyen 2014.02.14 18:56  
scfx:

Hello,

...

Hello,

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


This time, I edited it for you.

whroeder1
13593
whroeder1 2014.02.14 19: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?
Harry
267
Harry 2014.02.14 19: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
whroeder1
13593
whroeder1 2014.02.14 20: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
Harry
267
Harry 2014.02.14 21:37  
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.

/
To add comments, please log in or register