HELP: refer to the date of highest value

#16
I used the above code : ValueWhen(condition,Datetime()), then I can get the exact day, when say X == 0, but what if I want to show 1 day before X == 0?

can I use " DateTime() - 1"?

AddColumn( ValueWhen( X == 0, DateTime() - 1), "Date", formatDateTime );
AddColumn( ValueWhen( X == 0, Ref( C, -1 ) ), "Price of Date" );



thanks.
 
#17
Hi fish,

why u opened separate thread for date part?
 

sudris

Well-Known Member
#19
I used the above code : ValueWhen(condition,Datetime()), then I can get the exact day, when say X == 0, but what if I want to show 1 day before X == 0?

can I use " DateTime() - 1"?

AddColumn( ValueWhen( X == 0, DateTime() - 1), "Date", formatDateTime );
AddColumn( ValueWhen( X == 0, Ref( C, -1 ) ), "Price of Date" );



thanks.
better get the barindex() first. in this way : ValueWhen(condition,BarIndex());
Code:
mybar=ValueWhen(X == 0, BarIndex());
mybar--; // decrement by 1.

// if you want more then
// mybar = mybar - 2;  // for second previous bar. -3 for third previous...and so on provided the array element doesn't fall out of array size.

AddColumn( ValueWhen( mybar == BarIndex(), DateTime()), "Date", formatDateTime );
 

Similar threads