tszwun 發表於 14-6-7 18:32

Amibroker chart searching

大家好。請問有什麼方法可以令amibroker chart 可以用search function 之類跳去指定日期/時間?謝謝。

joshsmi 發表於 14-6-8 03:13

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 );

tszwun 發表於 14-6-8 10:18

OH!!!...真的謝謝你....完全沒想過可以用AFL...

osdak 發表於 14-6-8 14:24

joshsmi 發表於 14-6-8 03:13 static/image/common/back.gif
From the AmiBroker forum

//zoom to date/time by fxshrat


thanks x 2. as said, never imagine it could be done by AFL......

joshsmi 發表於 14-6-8 15:36

Anything can be done by AFL!

tszwun 發表於 14-6-8 17:09

不好意思,我想問一下我已經copy source save as AFL...how to call it out? 謝謝...

joshsmi 發表於 14-6-8 17:38

Drag&drop on chart, CTRL+R, choose parameters, and click button "CLICK HERE"


instead of
if( ParamTrigger( "Zoom?", "CLICK HERE" ) )

you can also use
if( GetASyncKeyState( ... )< 0 )

and/or mouse button functions
cmb      = GetCursorMouseButtons();
Lmouse    = cmb == 9;
etc.
頁: [1]
查看完整版本: Amibroker chart searching