|
由于AB没有提供指定日期跳转功能。一直使用以下AFL做日期跳转,但发现如果启动多个amibroker。那么,该AFL只对第一个有效,以后启动的怎么点图表都
不会动。
是不是以下VBA call导致只能识别内存中的第一个打开的Ami呢?
AB = CreateObject( "Broker.Application" );
AW = AB.ActiveWindow;
AW.ZoomToRange( BeginZoom, EndZoom);
AFL如下:
sDateStr = ParamStr("Goto example 2010/3/24 12:00:00", "");
bGoNow = ParamTrigger("Click Button to Go", "Click Here");
// require all bars, otherwise the index will not be correct
SetBarsRequired(-2, -2);
procedure ZoomChart(BeginZoom, EndZoom) {
AB = CreateObject( "Broker.Application" );
AW = AB.ActiveWindow;
AW.ZoomToRange( BeginZoom, EndZoom);
}
if(bGoNow AND StrLen(sDateStr) > 0) {
// Retrieve current indexes for visible bars
FirstBarIndex = Status( "firstvisiblebarindex" );
LastBarIndex = Status( "lastvisiblebarindex" );
nHalfScrRange = round( abs(LastBarIndex - FirstBarIndex) / 2);
DT = DateTime();
sDateStr = StrToUpper(sDateStr);
TargetMidBarIndex = 0;
for(i = 1; i < BarCount; i++) {
if (StrFind(DateTimeToStr(DT[i]), sDateStr) > 0) {
TargetMidBarIndex = i;
break;
}
}
if(TargetMidBarIndex > 0) {
// cap the bar index if it goes beyond BarCount
if (TargetMidBarIndex + nHalfScrRange > BarCount) {
BeginZoom = DateTimeToStr(DT[BarCount - 1 - nHalfScrRange * 2]);
EndZoom = DateTimeToStr(DT[BarCount - 1]);
}
else {
BeginZoom = DateTimeToStr(DT[TargetMidBarIndex - nHalfScrRange]);
EndZoom = DateTimeToStr(DT[TargetMidBarIndex + nHalfScrRange]);
}
// zoom to specified range
ZoomChart(BeginZoom, EndZoom);
// draw up/down triangle to highlight the identified bar
shapeArr[TargetMidBarIndex] = shapeUpTriangle;
PlotShapes(shapeArr, colorYellow, 0, Low[TargetMidBarIndex], -12);
shapeArr[TargetMidBarIndex] = shapeDownTriangle;
PlotShapes(shapeArr, colorYellow, 0, High[TargetMidBarIndex], -12);
}
}
_SECTION_END(); |
|