HELP: refer to the date of highest value

Joined
Dec 2, 2012
Messages
80
Likes
4
#14
it seems work. but it returns a big number.. how do I convert to the normal date format that I can see, i.e. 17/2/2013. Thanks
 
Joined
Dec 2, 2012
Messages
80
Likes
4
#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.
 

amanfree

Active Member
Joined
Sep 29, 2009
Messages
218
Likes
112
#17
Hi fish,

why u opened separate thread for date part?
 

sudris

Well-Known Member
Joined
May 3, 2011
Messages
457
Likes
548
#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

Broker Special Offers