Need help for afl

#1
Hi,

I am the beginner in AFL. I am trying to find whether for x stock y value occus on which date from the latest data. This should be displayed on the chart only. But I am unable to do that. Can somebody help me.

For Eg:

Allahabad bank closed price as on 14 May 2010 is 157.6 Rs. Now, I want to find when the last time it reached the 130 Rs. The answer should be 26 Feb, 2010. This should be printed on the chart.

Thanks.
 

colion

Active Member
#2
Not sure exactly what you are after but you can use ValueWhen() to find the date number when C < 130 (or any other condition) and then PlotText() to put the date on the chart at the place that you want. Something along these lines should work:

datenumber = ValueWhen( C < 130, DateNum(), 1 );

Then convert DateNum() to a date string such as "May 1, 2010" as shown in the Users Guide and then,

PlotText("May 1, 2010", (see Users Guide for the other parameters) );
 
#3
Hi colion,

Thanks for the reply. Actually, I am not able to convert DateNum() to date string. I tried DateTimetoStr() function, but its not giving me the desired results. Can you give me the snapshot of how to convert DateNum() to String.

Not sure exactly what you are after but you can use ValueWhen() to find the date number when C < 130 (or any other condition) and then PlotText() to put the date on the chart at the place that you want. Something along these lines should work:

datenumber = ValueWhen( C < 130, DateNum(), 1 );

Then convert DateNum() to a date string such as "May 1, 2010" as shown in the Users Guide and then,

PlotText("May 1, 2010", (see Users Guide for the other parameters) );
 

colion

Active Member
#4
Look at the Users Guide and see how datenum() is constructed. Datenum() is an array so you have to determine the datenum that you are interested in. Then you have to break the datenum number into parts that correspond to day, month and year, as defined in the Users Guide, using the functions StrLeft(), StrMid(), and StrRight() and then put them back together. For example, if dd = the string corresponding to the date, mm = string corresponding to the month, and yy = string corresponding to the year then the date = mm + "/" + dd + "/" + yy. There are examples in the library and User Knowledge Base that demonstrate this as well as how to plot the information on a chart.
 

Similar threads