|
From the AmiBroker forum
//zoom to date/time by fxshrat
procedure ZoomChart( Begindate, Enddate )
{
AB = CreateObject("Broker.Application");
AW = AB.ActiveWindow;
AW.ZoomToRange( Begindate, Enddate );
}
EnableTextOutput( 0 );
MidZoomdate = ParamDate( "Choose Date to search for", Now( 1 ), 0 );
MidZoomtime = ParamTime( "Choose Time to search for", "12:00:00" );
tmfrmmode = ParamList( "Choose Base Timeframe", "1-Second|1-Minute|5-Minute|10-Minute|15-Minute|30-Minute|Hourly|Daily|Weekly|Monthly", 7 );
switch( tmfrmmode )
{
case "1-Second": tmfrm = in1Second; break;
case "1-Minute": tmfrm = in1Minute; break;
case "5-Minute": tmfrm = in5Minute; break;
case "10-Minute": tmfrm = 2*in5Minute; break;
case "15-Minute": tmfrm = in15Minute; break;
case "30-Minute": tmfrm = 2*in15Minute; break;
case "Hourly": tmfrm = inHourly; break;
case "Daily": tmfrm = inDaily; break;
case "Weekly": tmfrm = inWeekly; break;
case "Monthly": tmfrm = inMonthly; break;
default: tmfrm = inDaily; break;
}
barvalue = -1;
if( tmfrm < Interval() )
tmfrm = Interval();
if( Interval() >= 86400 )
{
MidZoomtime = 0;
barvalue = -2;
}
Midzoom = DateTimeConvert( 2, Midzoomdate, MidZoomtime );
Beginzoom = DateTimeToStr( DateTimeAdd( Midzoom, barvalue, tmfrm ) );
Endzoom = DateTimeToStr( DateTimeAdd( Midzoom, 1, tmfrm ) );
EnableTextOutput( 1 );
if( ParamTrigger( "Zoom?", "CLICK HERE" ) )
ZoomChart( BeginZoom, EndZoom );
Plot( IIf( DateTime() == midzoom, BarIndex(), Null ), "", colorRed, styleHistogram | styleOwnScale, 0, 1, 0, -10, -10 );
|
|