Hi I am confused. Where are the button to enter different timeframes in the chart,
not daily or weekly I know the buttons but for example different
like from 1/1/2018 till now or till 1/10/2018. Thanks.
1 Like
There is no native chart date range selector (similar to analysis "From-to" date selector) to pin point date.
Either use Range markers or AFL+OLE (ZoomToRange, see sample code below)
ParamDate of AB version 6.20 has got additional feature of returning datetime format.
/// code works for native EOD bars as well as daily bars created out of intraday data
/// @link https://forum.amibroker.com/t/chart-set-timeframe-from-1-1-2018-till-now/10534/2
/// sample code by fxshrat@gmail.com
Version(6.20); // minimum AB version being required
zoom_activate = ParamToggle( "Activate Zoom", "OFF|ON", 0 );
start_date = ParamDate("Start Date", "2018-01-01", 2);
end_date = ParamDate( "End Date", Now(1), 2);
zoom_trigger = ParamTrigger( "Zoom to Date Range", "CLICK HERE" );
if ( zoom_activate ) {
SetBarsRequired( -2, -2 );
dt = DateTime();
Lookedup_start_dt = Lookup(dt, start_date, -2);
Lookedup_end_dt = Lookup(dt, end_date, -1);
start_dt = DateTimeFormat("%Y-%m-%d", Lookedup_start_dt);
end_dt = DateTimeFormat("%Y-%m-%d", Lookedup_end_dt);
printf("\nStart date: %s\nEnd date: %s", start_dt, end_dt);
if ( zoom_trigger ) {
AB = CreateObject( "Broker.Application" );
AW = AB.ActiveWindow;
AW.ZoomToRange( start_dt, end_dt );
}
}
Don't forget to turn "Activate zoom" toggle button to ON. Then select date range and hit "Click here" button
14 Likes
Thanks great help.