COCO研究院

 找回密碼
 註冊
搜索
查看: 4321|回復: 9

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

[複製鏈接]
發表於 12-7-21 18:15 | 顯示全部樓層 |閱讀模式

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

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

由於有 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


評分

參與人數 1金錢 +2 收起 理由
yccecily + 2 按一個讚!

查看全部評分

發表於 12-7-21 19:35 | 顯示全部樓層
週末愉快
發表於 12-7-22 16:26 | 顯示全部樓層
在 Bar Replay 視窗裡拉中間的時間軸 或 直接指定 Bar Replay 視窗中的起啟時間來改變目前顯示圖的時間, 可以達到這個需求. (雖然和您要的做法不太一樣.. 但應該勉強可用)
 樓主| 發表於 12-7-22 21:05 | 顯示全部樓層
sdnian 發表於 12-7-22 16:26
在 Bar Replay 視窗裡拉中間的時間軸 或 直接指定 Bar Replay 視窗中的起啟時間來改變目前顯示圖的時間, 可 ...



謝謝 S 大....
這方法對我而言..夠用了...
S大對 amibroker 真的很熟...竟然可以找出這種 trick...
真是厲害....
發表於 12-7-23 08:15 | 顯示全部樓層
哈.. 我只是剛好用這個功能..
發表於 12-7-23 14:46 | 顯示全部樓層
超讚的邏輯
挺有意思的
發表於 12-10-29 23:37 | 顯示全部樓層
本帖最後由 zaqimon 於 12-10-29 23:43 編輯

這是之前google到的
我有稍微修改了一下
請將最下方AFL放到Include資料夾內且命名為iZoomer.afl
然後在AmiBroker的每個Window內加入下面兩行即可
  1. UseZoomer = ParamToggle("Use Zoomer?", "No|Yes", 1);
  2. #include_once <iZoomer.afl>
複製代碼

不同timeframe不同symbol
不論scrolling或zooming都會同步
設定好interval或symbolic link後即可連Selected bar都能同步
除了scroll到最右側的right margin會有一點點bug不同步外
不過大致上不影響正常使用
擷取.PNG

  1. /*

  2. Synchronous scrolling on all windows in AmiBroker



  3. [20120915] zaqimon
  4. original AFL from htt[deleteme]p:/[deleteme]/finance.groups.yahoo.com/group/amibroker/message/141912
  5. I did a slight modification.


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

  11. */


  12. function ZqZoomSync( force )
  13. {
  14.     // All variables are made local to guarantee naming collisions or side effects
  15. //    local bv, dr, Curstdt, Curenddt, prevstdt, prevenddt, Curststr, Curendstr;
  16.     local LastBarIndex, FirstBarIndex, prevLastBarIndex, prevFirstBarIndex, prevFirstDateTime, DT, BI, LastDateTime, FirstDateTime, LastDateTimestr, FirstDateTimestr;
  17.     local OAB, OAD, dcount, i, OADoc, OAW, OADocWin, res;
  18.     // Get a count of the number of documents
  19.     OAB = CreateObject( "Broker.Application" );
  20.     OAD = OAB.Documents;
  21.     dcount = OAD.Count;
  22.     // Process multiple windows (documents)
  23.     res = False;
  24.     if ( dcount > 1 )
  25.     {
  26.         // Get current and last start and end DateTimes's
  27.         LastBarIndex = Status( "LastVisibleBarIndex" );
  28.         FirstBarIndex = Status( "FirstVisibleBarIndex" );
  29.         //Nblankbar = Status( "LastVisibleBarIndex" ) - BarCount; // [zq] not used !!
  30.         
  31.         // [zq] BarIndex may always be the same due to QuickAFL, check prevFirstDateTime in addition
  32.         prevLastBarIndex = Nz( StaticVarGet( "_prevLastVisibleBarIndex" ) );
  33.         prevFirstBarIndex = Nz( StaticVarGet( "_prevFirstVisibleBarIndex" ) );
  34.         prevFirstDateTime = Nz( StaticVarGet( "_prevFirstDateTime" ) );
  35.         
  36.         // [zq] move outside if() statement for checking prevFirstDateTime
  37.         DT = DateTime();
  38.         BI = BarIndex();
  39.         LastDateTime = LastValue( ValueWhen( LastBarIndex == BI, DT ) ); // [zq] LastDateTime could be empty
  40.         FirstDateTime = LastValue( ValueWhen( FirstBarIndex == BI, DT ) );
  41.         
  42.         // Check for a new date/time range
  43. //        _TRACE(""+FirstBarIndex+", "+LastBarIndex);
  44.         if ( LastBarIndex != prevLastBarIndex OR FirstBarIndex != prevFirstBarIndex OR FirstDateTime != prevFirstDateTime OR force )
  45.         {
  46.             // Set the new last values
  47.             StaticVarSet( "_prevLastVisibleBarIndex", LastBarIndex );
  48.             StaticVarSet( "_prevFirstVisibleBarIndex", FirstBarIndex );
  49.             StaticVarSet( "_prevFirstDateTime", FirstDateTime );
  50.             
  51.             LastDateTimestr = DateTimeToStr( LastDateTime );
  52.             FirstDateTimestr = DateTimeToStr( FirstDateTime );
  53. //            _TRACE(""+FirstDateTimestr+", "+LastDateTimestr);
  54.             // Loop through the document collection
  55.             for ( i = 0; i < dcount; i++ )
  56.             {
  57.                 // If it is not the active document -
  58.                 OADoc = OAD.Item( i );
  59.                 // NOTE - it doesn't hurt to sync the current window and it makes all
  60.                 // windows have no blank bars on the right so they look the same
  61.                 // [zq] I think it's reasonable for not syncing ActiveDocument.
  62.                 // [zq] Something not belong to the ActiveDocument was shown when not syncing ActiveDocument with multi-threaded charts options disabled.
  63.                 if ( OADoc != OAB.ActiveDocument )
  64.                 {
  65.                     // Get the document window and zoom to range
  66.                     //_TRACE( " Zoom to range document - " + i + " , " + Curststr + " - " + Curendstr );
  67.                     OADW = OADoc.Windows;
  68.                     // Document window count assumed to be 1
  69.                     OADocWin = OADW.Item( 0 );
  70.                     OADocWin.ZoomToRange( FirstDateTimestr, LastDateTimestr ); // [zq] this function failed to update chart at the right most margin with empty LastDateTimestr. Just minor issue, don't care.
  71.                 }
  72.             }
  73.             res = True;
  74.         }
  75.     }
  76.     return res;
  77. }

  78. //  Call for synchronization
  79. If (UseZoomer)
  80.      ZqZoomSync( False ); // [zq] set True will enter infinite loop if we also update ActiveDocument
複製代碼


評分

參與人數 2金錢 +7 收起 理由
enochyu + 2 按一個讚!
kilroy + 5 按一個讚!

查看全部評分

發表於 12-10-30 09:13 | 顯示全部樓層
蠻實用的,謝謝分享
發表於 12-11-10 00:00 | 顯示全部樓層
謝謝分享
發表於 12-11-19 20:00 | 顯示全部樓層
多謝大大的分享喔
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-5-4 23:59

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook