COCO研究院

 找回密碼
 註冊
搜索
查看: 2829|回復: 2

哪位大大可指点一下多个AB窗口的问题

[複製鏈接]
發表於 11-9-4 13:42 | 顯示全部樓層 |閱讀模式
由于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();
發表於 11-9-4 15:21 | 顯示全部樓層
這個太專業了~
發表於 11-9-5 21:33 | 顯示全部樓層
在海洋部落看過人家寫的日期跳轉
但似乎沒提到多個Amibroker Instance的這種問題
這個可能要實際用過的人,才能查問題何在了
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-6-23 09:40

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 |