hipper68 發表於 12-7-21 18:15

不同週期、不同 chart間的同步..


爬了一天的文章...還是沒有找到方法...
請教各位大大了...

我的需求:
1.開兩個 interval 的k線圖, 如下圖 5min & 10min..
2.看5分K時, 點k線時, 10分點也會被highlight ...
   (這部份使用 symbol link 即可以達成)...
3.看完此頁的 K線圖之後, 在5分k往前拉之後, 10分k是否也可以"自動" 往前拉 ???
    (找不到方法!!!)


由於有 review 不同週期歷史K線的需求, 所以會希望能做到不同週期k線的自動同步...以方便觀看...
請教各位大大是否能做到...???


=====題外話分隔線============

爬文過程找到一個有趣的功能...視窗連動 (linked chart)
(http://www.coco-in.net/thread-8042-1-9.html 五樓)
從官方的說明是可以使用不同的 interval...但是我一改 interval, 都會一起改...
官方說明..

[*]Linked Chart
Creates linked chart window based on current template and active chart. Linked windows use the same symbol selection, so if you change the selected symbol for one of them, the other one will synchronize automatically. Linked windows can have DIFFERENT viewing time frame selected. Simply activate the window and select desired interval from View menu for one window, then switch to the other one and select different interval for it.This option allows you to select different time frame or indicators' set in each window and easily move through the database


water 發表於 12-7-21 19:35

週末愉快{:4_209:}{:4_209:}

sdnian 發表於 12-7-22 16:26

在 Bar Replay 視窗裡拉中間的時間軸 或 直接指定 Bar Replay 視窗中的起啟時間來改變目前顯示圖的時間, 可以達到這個需求. (雖然和您要的做法不太一樣.. 但應該勉強可用)

hipper68 發表於 12-7-22 21:05

sdnian 發表於 12-7-22 16:26 static/image/common/back.gif
在 Bar Replay 視窗裡拉中間的時間軸 或 直接指定 Bar Replay 視窗中的起啟時間來改變目前顯示圖的時間, 可 ...



謝謝 S 大....
這方法對我而言..夠用了...
S大對 amibroker 真的很熟...竟然可以找出這種 trick...
真是厲害....

sdnian 發表於 12-7-23 08:15

哈.. 我只是剛好用這個功能..

jo5918 發表於 12-7-23 14:46

超讚的邏輯
挺有意思的
{:4_93:}

zaqimon 發表於 12-10-29 23:37

本帖最後由 zaqimon 於 12-10-29 23:43 編輯

這是之前google到的
我有稍微修改了一下
請將最下方AFL放到Include資料夾內且命名為iZoomer.afl
然後在AmiBroker的每個Window內加入下面兩行即可
UseZoomer = ParamToggle("Use Zoomer?", "No|Yes", 1);
#include_once <iZoomer.afl>
不同timeframe不同symbol
不論scrolling或zooming都會同步
設定好interval或symbolic link後即可連Selected bar都能同步
除了scroll到最右側的right margin會有一點點bug不同步外
不過大致上不影響正常使用


/*

Synchronous scrolling on all windows in AmiBroker



zaqimon
original AFL from http://finance.groups.yahoo.com/group/amibroker/message/141912
I did a slight modification.


<Usage>
Put this AFL in the Include Folder.
Add below 2 lines into your AFL
UseZoomer = ParamToggle("Use Zoomer?", "No|Yes", 0);
#include_once <iZoomer.afl>

*/


function ZqZoomSync( force )
{
    // All variables are made local to guarantee naming collisions or side effects
//    local bv, dr, Curstdt, Curenddt, prevstdt, prevenddt, Curststr, Curendstr;
    local LastBarIndex, FirstBarIndex, prevLastBarIndex, prevFirstBarIndex, prevFirstDateTime, DT, BI, LastDateTime, FirstDateTime, LastDateTimestr, FirstDateTimestr;
    local OAB, OAD, dcount, i, OADoc, OAW, OADocWin, res;
    // Get a count of the number of documents
    OAB = CreateObject( "Broker.Application" );
    OAD = OAB.Documents;
    dcount = OAD.Count;
    // Process multiple windows (documents)
    res = False;
    if ( dcount > 1 )
    {
      // Get current and last start and end DateTimes's
      LastBarIndex = Status( "LastVisibleBarIndex" );
      FirstBarIndex = Status( "FirstVisibleBarIndex" );
      //Nblankbar = Status( "LastVisibleBarIndex" ) - BarCount; // not used !!
      
      // BarIndex may always be the same due to QuickAFL, check prevFirstDateTime in addition
      prevLastBarIndex = Nz( StaticVarGet( "_prevLastVisibleBarIndex" ) );
      prevFirstBarIndex = Nz( StaticVarGet( "_prevFirstVisibleBarIndex" ) );
      prevFirstDateTime = Nz( StaticVarGet( "_prevFirstDateTime" ) );
      
      // move outside if() statement for checking prevFirstDateTime
      DT = DateTime();
      BI = BarIndex();
      LastDateTime = LastValue( ValueWhen( LastBarIndex == BI, DT ) ); // LastDateTime could be empty
      FirstDateTime = LastValue( ValueWhen( FirstBarIndex == BI, DT ) );
      
      // Check for a new date/time range
//      _TRACE(""+FirstBarIndex+", "+LastBarIndex);
      if ( LastBarIndex != prevLastBarIndex OR FirstBarIndex != prevFirstBarIndex OR FirstDateTime != prevFirstDateTime OR force )
      {
            // Set the new last values
            StaticVarSet( "_prevLastVisibleBarIndex", LastBarIndex );
            StaticVarSet( "_prevFirstVisibleBarIndex", FirstBarIndex );
            StaticVarSet( "_prevFirstDateTime", FirstDateTime );
            
            LastDateTimestr = DateTimeToStr( LastDateTime );
            FirstDateTimestr = DateTimeToStr( FirstDateTime );
//            _TRACE(""+FirstDateTimestr+", "+LastDateTimestr);
            // Loop through the document collection
            for ( i = 0; i < dcount; i++ )
            {
                // If it is not the active document -
                OADoc = OAD.Item( i );
                // NOTE - it doesn't hurt to sync the current window and it makes all
                // windows have no blank bars on the right so they look the same
                // I think it's reasonable for not syncing ActiveDocument.
                // Something not belong to the ActiveDocument was shown when not syncing ActiveDocument with multi-threaded charts options disabled.
                if ( OADoc != OAB.ActiveDocument )
                {
                  // Get the document window and zoom to range
                  //_TRACE( " Zoom to range document - " + i + " , " + Curststr + " - " + Curendstr );
                  OADW = OADoc.Windows;
                  // Document window count assumed to be 1
                  OADocWin = OADW.Item( 0 );
                  OADocWin.ZoomToRange( FirstDateTimestr, LastDateTimestr ); // this function failed to update chart at the right most margin with empty LastDateTimestr. Just minor issue, don't care.
                }
            }
            res = True;
      }
    }
    return res;
}

//Call for synchronization
If (UseZoomer)
   ZqZoomSync( False ); // set True will enter infinite loop if we also update ActiveDocument

moneymaker 發表於 12-10-30 09:13

蠻實用的,謝謝分享{:4_209:}

heavenweaver 發表於 12-11-10 00:00

謝謝分享{:4_113:}{:5_658:}

acerman 發表於 12-11-19 20:00

多謝大大的分享喔
頁: [1]
查看完整版本: 不同週期、不同 chart間的同步..