Is it possible to run Exploration for past date

abcpankaj

Active Member
#1
Is it possible to run a amibroker Exploration for a particular date in past.
Metastock provides this option but how can this be done in Amibroker.

Thanks in advance
 

trash

Well-Known Member
#2
3 versions: first one using just time search, second one using time and date and third one just using date but with option time still in code but commented
Use parameter dialog in AA window to choose time or date

Code:
//time search by trash
sTime = ParamTime("Time to search", "09:00:00"); 
numstr = NumToStr(stime, 1, False);

if(stime <100000)
 timestr = StrLeft(numstr, 1)+":"+StrMid(numstr,1,2)+":"+StrRight(numstr, 2);
else
 timestr = StrLeft(numstr, 2)+":"+StrMid(numstr,2,2)+":"+StrRight(numstr, 2);

SetOption("NoDefaultColumns",True);
SetSortColumns( -3 ); //sort by third column, change to your needs or comment it

Filter = TimeNum() == stime;

AddTextColumn(Name(),"Ticker",1.0,colorWhite,colorDarkGrey,70);
AddColumn(DayOfWeek(),"WKD",1.0,colorWhite,colorDarkGrey,35);
AddColumn(DateTime(),"Date/Time",formatDateTime, colorBlack,colorGrey50,120);
AddColumn(Close,"Close @ "+ timestr, 1.2, colorWhite,colorDarkGrey,90);
Code:
//date and time search by trash

sDate = ParamDate("Date to search", "2012/05/03" );
sTime = ParamTime("Time to search", "09:00:00");
numstr = NumToStr(stime, 1, False);

if(stime <100000)
 timestr = StrLeft(numstr, 1)+":"+StrMid(numstr,1,2)+":"+StrRight(numstr, 2);
else
 timestr = StrLeft(numstr, 2)+":"+StrMid(numstr,2,2)+":"+StrRight(numstr, 2);

SetOption("NoDefaultColumns",True);
 
Filter = DateNum() == sdate AND TimeNum() == sTime;

AddTextColumn(Name(),"Ticker",1.0,colorWhite,colorDarkGrey,70);
AddColumn(DayOfWeek(),"WKD",1.0,colorWhite,colorDarkGrey,35);
AddColumn(DateTime(),"Date/Time",formatDateTime, colorBlack,colorGrey50,120);
AddColumn(Close,"Close @ "+ timestr, 1.2, colorWhite,colorDarkGrey,90);
Code:
//date search (time options commented) by trash

sDate = ParamDate("Date to search", "2012/05/03" );
/*sTime = ParamTime("Time to search", "09:00:00"); 
numstr = NumToStr(stime, 1, False);

if(stime <100000)
 timestr = StrLeft(numstr, 1)+":"+StrMid(numstr,1,2)+":"+StrRight(numstr, 2);
else
 timestr = StrLeft(numstr, 2)+":"+StrMid(numstr,2,2)+":"+StrRight(numstr, 2);
*/

SetOption("NoDefaultColumns",True);
 
Filter = DateNum() == sdate /*AND TimeNum() == sTime*/;

AddTextColumn(Name(),"Ticker",1.0,colorWhite,colorDarkGrey,70);
AddColumn(DayOfWeek(),"WKD",1.0,colorWhite,colorDarkGrey,35);
AddColumn(DateTime(),"Date/Time",formatDateTime, colorBlack,colorGrey50,120);
AddColumn(Close,"Close" /*@ "+ timestr*/, 1.2, colorWhite,colorDarkGrey,90);
 
Last edited:

trash

Well-Known Member
#3
BTW, Metastock is overpriced dinosaur and AB is much more powerful. There is not much that can't be done in AB.
 

abcpankaj

Active Member
#4
Thank you so much 'trash' for your reply.
I do appreciate the logic behind the code, its superb.

Filter = DateNum() == sdate;

In above line DateNum() is always considered as date of last entry in database .Hence the filter is set as zero for all other (past) dates , at my end.
Trying to work around this issue.

Thanks for your help.
Regards,
 

abcpankaj

Active Member
#5
Instead of setting the exact date using -> ParamTime("Time to search", "09:00:00");
I tried relative date through-> Ref(DateNum(),-3)
But the filter still (quite logically) fails .

Guess there is some other parameter for the date on which user wants to run the explore.
Which should be set by ParamDate("Date to search", "2012/04/04" );
or Ref(DateNum(),-3);
Filter does not seems to be the best place to control the date to run the explorer.

Best Regards
 

trash

Well-Known Member
#6
Thank you so much 'trash' for your reply.
I do appreciate the logic behind the code, its superb.

Filter = DateNum() == sdate;

In above line DateNum() is always considered as date of last entry in database .Hence the filter is set as zero for all other (past) dates , at my end.
Trying to work around this issue.

Thanks for your help.
Regards,
What do you mean? It's not looking for last entry of data base. It searches the date you choose in parameters. That's what you wanted.

You wrote
Is it possible to run a amibroker Exploration for a particular date in past.
If this is not what you want then you should tell in clear words what you are looking for.

You choose the date via parameter dialog.
And ParamTime is not Date. It's Parameter function for time.
Since you don't seem to need time here is the code just using date only.

Code:
sDate = ParamDate("Date to search", "2012/05/03" );

SetOption("NoDefaultColumns",True);
 
Filter = DateNum() == sdate;

AddTextColumn(Name(),"Ticker",1.0,colorWhite,colorDarkGrey,70);
AddColumn(DayOfWeek(),"WKD",1.0,colorWhite,colorDarkGrey,35);
AddColumn(DateTime(),"Date/Time",formatDateTime, colorBlack,colorGrey50,120);
AddColumn(Close,"Close", 1.2, colorWhite,colorDarkGrey,90);
Also if you wanna search in daily time frame you should set to daily in AA settings
See here (picture quality is not the best but doesn't matter)
 
Last edited:

abcpankaj

Active Member
#7
This is exactly how I wanted it to be & that's how it is working now.
The issue was with my setting of Range.

Even when the date chosen through parameter was between the set date range , it used to throw blank result.On setting the Range radio button (AB version 5.4) to 'all quotations' it worked smoothly.

Thank you so much for taking all the trouble

Regards,
 

Similar threads