find date of bar or event

#1
hi all

I would like your help please

period1=80;

HIPOINT=hhv( High, period1) ; //this will return value

BARNUMBER=HHVBars( High, period1) ; //this will return bar number


AddColumn(C , "close", 1.2 , colorDefault,colorDefault,-1);
AddColumn(HIPOINT, "HIPOINT", 1.2 , colorDefault,colorDefault,-1);
AddColumn(BARNUMBER, "BARNUMBER", 1.2 , colorDefault,colorDefault,-1);

how to find the date of ( BARNUMBER )

thank you for your help
 

copypasteaee

Humbled by Markets
#2
HIPOINT=hhv( High, period1) ; //this will return value

BARNUMBER=Valuewhen(HIPOINT, Barindex());
 

trash

Well-Known Member
#4
HIPOINT=hhv( High, period1) ; //this will return value

BARNUMBER=Valuewhen(HIPOINT, Barindex());
That is wrong because first argument of valuewhen function has to be a condition returning true or false but your hipoint variable is not a condition but just a price array.

Anyway as for the first post it is pretty simple:


Code:
periods1 = 80;
bars = HHVBars( H, periods1);
dt = Ref( DateTime(), -bars );
 
#5
That is wrong because first argument of valuewhen function has to be a condition returning true or false but your hipoint variable is not a condition but just a price array.

Anyway as for the first post it is pretty simple:


Code:
periods1 = 80;
bars = HHVBars( H, periods1);
dt = Ref( DateTime(), -bars );

it is return number not date (824,633,655,296.00)
I try to do it like this
dt = Ref( Date(), -bars );

but I get error

thank you
 

trash

Well-Known Member
#9
it is return number not date (824,633,655,296.00)
I try to do it like this
dt = Ref( Date(), -bars );

but I get error

thank you
Nonsense!
Would you please care to read the AB help.

Code:
periods1 = 80; 

hi = HHV( H, periods1);
bars = HHVBars( H, periods1); 

dt = DateTime();
dthigh = Ref( dt, -bars );

Filter = 1;
format = 1.2;

AddColumn(C , "close", format, -1,-1);
AddColumn(Hi, "HHV", format, -1,-1);
AddColumn(bars, "Bars", 1, -1,-1);
AddColumn(dthigh, "DateTime of HHV", [b][color=#990000]formatDateTime[/color][/b], -1,-1, 120);
As for Date() function.. it returns string!!
Again would you please care to read the AB help instead of dancing in the dark.
 

LOVEENAJYOTHI

Well-Known Member
#10
I get number not date

TRY Now
Code:
function DateNumToStr(DtNum)
{
  DayNm = round(frac(DtNum/100)*100);
  MthNm = round(frac(DtNum/10000)*100);
  YrNm = int(DtNum/10000)+1900;
  return NumToStr(DayNm,1.0)+"/"+NumToStr(MthNm,1.0)+"/"+NumToStr(YrNm,1.0,False);
}   



period1=80;

HIPOINT=ValueWhen(H=HHV( High, period1), H ,1) ; //this will return Most Recent HIPOINT

BARNUMBER=ValueWhen(HIPOINT, BI, 1); //this will b bar number of Most Recent HIPOINT

HiPointDtNum=ValueWhen(BARNUMBER ,DateNum() ,1); //DtNum of BARNUMBER

HiPointDATE=DateNumToStr(HiPointDtNum);  //Date of BarNumber in DD/MM/YYYY format, u can change the format in above DtNumToStr  function

Title= "HIPOINT"+"     "+ HIPOINT + "        " + "HIPOINTDATE"+ "     "+ +HiPointDATE;    // will display HIPOINT & HiPointDt on ur Chart Title
 

Similar threads