COCO研究院

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

不同週期的同步

[複製鏈接]
發表於 11-8-13 02:35 | 顯示全部樓層 |閱讀模式
  1. n=Param("TM",5,1,60,1);
  2. n_open = TimeFrameGetPrice("O",n*in1Minute,0,expandPoint);
  3. n_high = TimeFrameGetPrice("H",n*in1Minute,0,expandPoint);
  4. n_low = TimeFrameGetPrice("L",n*in1Minute,0,expandPoint);
  5. n_close = TimeFrameGetPrice("C",n*in1Minute,0,expandPoint);

  6. color = ParamColor("color",colorRed);
  7. PlotOHLC(n_open,n_high,n_low,n_close,"TM",color,styleCandle,);
複製代碼
這是網路上抄來的 ,借我紀錄一下;
重要的是他有同步,只是圖形不能展開到小週期的時間軸裡面.
不同週期.jpg

評分

參與人數 2金錢 +4 收起 理由
Rich-888 + 2 感謝分享
Billions+ + 2 按一個讚

查看全部評分

發表於 11-8-13 10:36 | 顯示全部樓層
只是圖形不能展開到小週期的時間軸裡面....
unbattle 發表於 11-8-13 02:35 AM
圖形不能展開到小週期的時間軸裡面?
意思是這樣嗎?

111.png

評分

參與人數 2金錢 +4 收起 理由
Rich-888 + 2
Billions+ + 2 按一個讚

查看全部評分

 樓主| 發表於 11-8-13 12:34 | 顯示全部樓層
應該是把1分鐘圖包含在5k裡面
縮小看5K 10K的型態 趨勢
放大看內部的1k有沒有比較有利的點位.
發表於 11-8-13 14:28 | 顯示全部樓層
應該是把1分鐘圖包含在5k裡面
縮小看5K 10K的型態 趨勢
放大看內部的1k有沒有比較有利的點位. ...
unbattle 發表於 11-8-13 12:34 PM


大大~ 這類的還不少喔

1K in 5K
dd.png
   
  1. _SECTION_BEGIN("2 Timeframes Candlestick Bar Chart");

  2. Version(5.21);
  3. SetChartOptions(2, chartShowDates);
  4. Title = Name();
  5. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  6. // PARAMETERS AND SETTINGS:
  7. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  8. ChartLum                 = Param("Chart Background Color Intensity", 0.40, 0, 1, 0.01);
  9. TFMinShort                = Param("Short Timeframe (Minutes)", 1, 1, 60, 1);
  10. TFMinLong                 = Param("Long Timeframe (Minutes)", 5, 1, 60, 1);
  11. OnSTFBars                = ParamToggle("Short TF Bars", "Off, On", 1);
  12. OnLTFBars                = ParamToggle("Long TF Bars", "Off, On", 1);
  13. BarLum1                 = Param("Short TF Bar Color Intensity", 0, 0, 1, 0.01);
  14. BarLum2                 = Param("Long TF Bar Color Intensity", 0.70, 0, 1, 0.01);

  15. SetChartBkColor(ColorBlend(colorLightBlue, colorWhite, ChartLum));
  16. // Bar Colors for the Short Timeframe candlestick bars:
  17. LineColor                 = ColorBlend(colorBlack, colorWhite, BarLum1);
  18. UpBarColor                = ColorBlend(colorRed, colorWhite, BarLum1);
  19. DnBarColor                = ColorBlend(colorBrightGreen , colorWhite, BarLum1);
  20. // Bar Colors For The Long Timeframe candlestick bars:
  21. TFLineColor         = ColorBlend(colorBlack, colorWhite, BarLum2 - 0.1);
  22. TFUpBarColor        = ColorBlend(colorRed , colorWhite, BarLum2);
  23. TFDnBarColor        = ColorBlend(colorBrightGreen , colorWhite, BarLum2);
  24. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  25. // FUNCTIONS:
  26. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  27. function GetVisibleBarCount()
  28. {
  29. lvb = Status("lastvisiblebar");
  30. fvb = Status("firstvisiblebar");
  31. return Min( Lvb - fvb, BarCount - fvb );
  32. }

  33. function GfxConvertBarToPixelX( bar )
  34. {
  35. lvb = Status("lastvisiblebar");
  36. fvb = Status("firstvisiblebar");
  37. pxchartleft = Status("pxchartleft");
  38. pxchartwidth = Status("pxchartwidth");
  39. return pxchartleft + bar  * pxchartwidth / ( Lvb - fvb + 1 );
  40. }

  41. function GfxConvertValueToPixelY( Value )
  42. {
  43. local Miny, Maxy, pxchartbottom, pxchartheight;
  44. Miny = Status("axisminy");
  45. Maxy = Status("axismaxy");
  46. pxchartbottom = Status("pxchartbottom");
  47. pxchartheight = Status("pxchartheight");
  48. return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight/ ( Maxy -
  49. Miny ) );
  50. }

  51. StaticVarKey = Name();
  52. procedure xStaticVarSet(SName, SValue)
  53. {
  54. global StaticVarKey;
  55. if (StaticVarKey != "")
  56.         StaticVarSet(Sname + StaticVarKey, Svalue);
  57. }
  58. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  59. // MAIN PROGRAM:
  60. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  61. if(Interval() != TFMinShort * 60)
  62. {
  63. Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "Set the chart
  64. time Interval to: " + NumToStr(TFMinShort, 1.0, 1) +
  65.                                         " Minute(s) or change the Short Timeframe Parameter setting.";
  66. OnSTFBars                = 0;
  67. OnLTFBars                = 0;
  68. SetChartBkColor(colorRose);
  69. }

  70. if(TFMinShort >= TFMinLong)
  71. {
  72. Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "The Long
  73. Timeframe setting must be longer than the Short Timeframe!";
  74. OnSTFBars                = 0;
  75. OnLTFBars                = 0;
  76. SetChartBkColor(colorRose);
  77. }

  78. if(OnSTFBars)
  79. {
  80. BarColor                = IIf(Close > Open, UpBarColor, DnBarColor);
  81. SetBarFillColor(BarColor);
  82. Plot(Close, "", LineColor, styleCandle);
  83. }
  84. else
  85. Plot(Close, "", colorBlack, styleCandle  | styleNoDraw);

  86. TFSec = in1Minute * TFMinLong;
  87. TimeFrameSet(TFSec);
  88. TFOpen                         = Open;
  89. TFHigh                         = High;
  90. TFLow                                 = Low;
  91. TFClose                        = Close;
  92. TFBarIndex                        = BarIndex();
  93. TFLastBarIndex        = LastValue(BarIndex());
  94. TimeFrameRestore();

  95. TFOpen                         = TimeFrameExpand(TFOpen, TFSec, expandFirst);
  96. TFHigh                         = TimeFrameExpand(TFHigh, TFSec, expandFirst);
  97. TFLow                                 = TimeFrameExpand(TFLow, TFSec, expandFirst);
  98. TFClose                        = TimeFrameExpand(TFClose, TFSec, expandFirst);
  99. TFBarIndex                        = TimeFrameExpand(TFBarIndex, TFSec, expandLast + 1);
  100. TFLastBarIndex        = TimeFrameExpand(TFLastBarIndex, TFSec, expandLast + 1);

  101. CandleTop                         = Max(TFOpen, TFClose);
  102. CandleBottom                = Min(TFOpen, TFClose);
  103. //============================================================================
  104. // GFX LOW-LEVEL GRAPHICS SECTION.
  105. // DRAWING THE LONG TIMEFRAME CANDLESTICK BARS:
  106. //============================================================================
  107. if(OnLTFBars)
  108. {
  109. GfxSetOverlayMode(1);
  110. AllVisibleBars         = GetVisibleBarCount();
  111. fvb                                = Status("firstvisiblebar");
  112. ChartWidth                = GfxConvertBarToPixelX(AllVisibleBars );
  113. PixBar                         = ChartWidth / AllVisibleBars;
  114. Adjust                        = Pixbar * 0.35;
  115. TFMinutes                 = TFMinLong / TFMinShort;
  116. NewTFBar                         = IIf(TFBarIndex != Ref(TFBarIndex, -1), 1, 0);
  117. BarInd                        = BarIndex();
  118. TFLastBarIndex        = LastValue(TFLastBarIndex);

  119. // DRAW BAR HISTORY AND THE CURRENT BAR:
  120. for(i = 0; i < AllVisibleBars; i++)
  121. {
  122.   x1 = GfxConvertBarToPixelX(i) * NewTFBar[i + fvb] - Adjust;
  123.   if(BarInd[i + fvb] < TFLastBarIndex AND NewTFBar[i + fvb] == 1)
  124.          {
  125.                 Counter = 0;
  126.                 for(n = i + 1; NewTFBar[n + fvb] == 0 AND n + fvb < BarCount-1; n++)
  127.                         Counter++;
  128.                 x2 = GfxConvertBarToPixelX(i + Counter) * NewTFBar[i + fvb] + 1 + Adjust;
  129.          }

  130.   if(TFBarIndex[i + fvb] == TFLastBarIndex)
  131.         x2 = GfxConvertBarToPixelX(i + TFMinutes - 1) * NewTFBar[i + fvb] + 1 +
  132. Adjust;

  133.    y1 = GfxConvertValueToPixelY(CandleTop[i + fvb]);
  134.    y2 = GfxConvertValueToPixelY(CandleBottom[i + fvb]);
  135.    yH = GfxConvertValueToPixelY(TFHigh[i + fvb]);
  136.    yL = GfxConvertValueToPixelY(TFLow[i + fvb]);

  137.    // Candle Body:
  138.    GfxSelectPen(TFLineColor, 0);
  139.    FillColor = IIf(TFOpen[i + fvb] < TFClose[i + fvb], TFUpBarColor,
  140. TFDnBarColor);
  141.    GfxSelectSolidBrush(FillColor);
  142.    if(y1 == y2){y1 = y1 - Adjust; y2 = y2 + Adjust;
  143. GfxSelectSolidBrush(TFLineColor);}
  144.    if(x1 > 0){
  145.    GfxRectangle( x1, y1, x2, y2);
  146.    // Candle High and Low:
  147.    GfxSelectPen(TFLineColor, 2);
  148.    GfxMoveTo(x2+(x1-x2)/2, y1);
  149.    GfxLineTo(x2+(x1-x2)/2, yH);
  150.    GfxMoveTo(x2+(x1-x2)/2, y2);
  151.    GfxLineTo(x2+(x1-x2)/2, yL);
  152.    RequestTimedRefresh(0);
  153.         }
  154. }
  155. }
  156. _SECTION_END();
複製代碼


參考看看了~~

評分

參與人數 2金錢 +4 收起 理由
Rich-888 + 2 太強了
Billions+ + 2 太強了

查看全部評分

 樓主| 發表於 11-8-13 15:32 | 顯示全部樓層
論壇上有寫這個需要5.2以上版本  
晚上去國外偷渡5.3的來用用看

感謝
發表於 11-8-15 19:39 | 顯示全部樓層
參考看看,謝謝分享
發表於 11-8-31 00:05 | 顯示全部樓層
回復 1# unbattle


unbattle 大大 ,, 我是Amibroker的初學摸索者 , 看到您 PO這篇 [不同周期的同步] 很不錯 ,,

可否麻煩有空 step by step 教我一下 ,要如何做才能像您圖上把二個周期的K線圖上下擺置好 ,

感謝您 ^_^
發表於 11-9-4 03:08 | 顯示全部樓層
謝謝分享這麼有用的技巧 !
發表於 13-6-20 19:30 | 顯示全部樓層
如果把這個要用於日線與週線上是不是可以?
若是要改要如何改?
謝謝告知的大大!
發表於 13-6-23 19:31 | 顯示全部樓層
kilroy 發表於 11-8-13 14:28
大大~ 這類的還不少喔

1K in 5K

學習~

感謝大大分享!!



您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-4-29 10:53

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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