unbattle 發表於 11-8-13 02:35

不同週期的同步

n=Param("TM",5,1,60,1);
n_open = TimeFrameGetPrice("O",n*in1Minute,0,expandPoint);
n_high = TimeFrameGetPrice("H",n*in1Minute,0,expandPoint);
n_low = TimeFrameGetPrice("L",n*in1Minute,0,expandPoint);
n_close = TimeFrameGetPrice("C",n*in1Minute,0,expandPoint);

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

ironheart 發表於 11-8-13 10:36

只是圖形不能展開到小週期的時間軸裡面....
unbattle 發表於 11-8-13 02:35 AM http://www.coco-in.net/images/common/back.gif圖形不能展開到小週期的時間軸裡面?
意思是這樣嗎?

unbattle 發表於 11-8-13 12:34

應該是把1分鐘圖包含在5k裡面
縮小看5K 10K的型態 趨勢
放大看內部的1k有沒有比較有利的點位.

kilroy 發表於 11-8-13 14:28

應該是把1分鐘圖包含在5k裡面
縮小看5K 10K的型態 趨勢
放大看內部的1k有沒有比較有利的點位. ...
unbattle 發表於 11-8-13 12:34 PM http://www.coco-in.net/images/common/back.gif

大大~ 這類的還不少喔

1K in 5K

   
_SECTION_BEGIN("2 Timeframes Candlestick Bar Chart");

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

SetChartBkColor(ColorBlend(colorLightBlue, colorWhite, ChartLum));
// Bar Colors for the Short Timeframe candlestick bars:
LineColor                 = ColorBlend(colorBlack, colorWhite, BarLum1);
UpBarColor                = ColorBlend(colorRed, colorWhite, BarLum1);
DnBarColor                = ColorBlend(colorBrightGreen , colorWhite, BarLum1);
// Bar Colors For The Long Timeframe candlestick bars:
TFLineColor         = ColorBlend(colorBlack, colorWhite, BarLum2 - 0.1);
TFUpBarColor        = ColorBlend(colorRed , colorWhite, BarLum2);
TFDnBarColor        = ColorBlend(colorBrightGreen , colorWhite, BarLum2);
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// FUNCTIONS:
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function GetVisibleBarCount()
{
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
return Min( Lvb - fvb, BarCount - fvb );
}

function GfxConvertBarToPixelX( bar )
{
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxchartleft = Status("pxchartleft");
pxchartwidth = Status("pxchartwidth");
return pxchartleft + bar* pxchartwidth / ( Lvb - fvb + 1 );
}

function GfxConvertValueToPixelY( Value )
{
local Miny, Maxy, pxchartbottom, pxchartheight;
Miny = Status("axisminy");
Maxy = Status("axismaxy");
pxchartbottom = Status("pxchartbottom");
pxchartheight = Status("pxchartheight");
return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight/ ( Maxy -
Miny ) );
}

StaticVarKey = Name();
procedure xStaticVarSet(SName, SValue)
{
global StaticVarKey;
if (StaticVarKey != "")
        StaticVarSet(Sname + StaticVarKey, Svalue);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// MAIN PROGRAM:
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if(Interval() != TFMinShort * 60)
{
Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "Set the chart
time Interval to: " + NumToStr(TFMinShort, 1.0, 1) +
                                        " Minute(s) or change the Short Timeframe Parameter setting.";
OnSTFBars                = 0;
OnLTFBars                = 0;
SetChartBkColor(colorRose);
}

if(TFMinShort >= TFMinLong)
{
Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "The Long
Timeframe setting must be longer than the Short Timeframe!";
OnSTFBars                = 0;
OnLTFBars                = 0;
SetChartBkColor(colorRose);
}

if(OnSTFBars)
{
BarColor                = IIf(Close > Open, UpBarColor, DnBarColor);
SetBarFillColor(BarColor);
Plot(Close, "", LineColor, styleCandle);
}
else
Plot(Close, "", colorBlack, styleCandle| styleNoDraw);

TFSec = in1Minute * TFMinLong;
TimeFrameSet(TFSec);
TFOpen                         = Open;
TFHigh                         = High;
TFLow                                 = Low;
TFClose                        = Close;
TFBarIndex                        = BarIndex();
TFLastBarIndex        = LastValue(BarIndex());
TimeFrameRestore();

TFOpen                         = TimeFrameExpand(TFOpen, TFSec, expandFirst);
TFHigh                         = TimeFrameExpand(TFHigh, TFSec, expandFirst);
TFLow                                 = TimeFrameExpand(TFLow, TFSec, expandFirst);
TFClose                        = TimeFrameExpand(TFClose, TFSec, expandFirst);
TFBarIndex                        = TimeFrameExpand(TFBarIndex, TFSec, expandLast + 1);
TFLastBarIndex        = TimeFrameExpand(TFLastBarIndex, TFSec, expandLast + 1);

CandleTop                         = Max(TFOpen, TFClose);
CandleBottom                = Min(TFOpen, TFClose);
//============================================================================
// GFX LOW-LEVEL GRAPHICS SECTION.
// DRAWING THE LONG TIMEFRAME CANDLESTICK BARS:
//============================================================================
if(OnLTFBars)
{
GfxSetOverlayMode(1);
AllVisibleBars         = GetVisibleBarCount();
fvb                                = Status("firstvisiblebar");
ChartWidth                = GfxConvertBarToPixelX(AllVisibleBars );
PixBar                         = ChartWidth / AllVisibleBars;
Adjust                        = Pixbar * 0.35;
TFMinutes                 = TFMinLong / TFMinShort;
NewTFBar                         = IIf(TFBarIndex != Ref(TFBarIndex, -1), 1, 0);
BarInd                        = BarIndex();
TFLastBarIndex        = LastValue(TFLastBarIndex);

// DRAW BAR HISTORY AND THE CURRENT BAR:
for(i = 0; i < AllVisibleBars; i++)
{
x1 = GfxConvertBarToPixelX(i) * NewTFBar - Adjust;
if(BarInd < TFLastBarIndex AND NewTFBar == 1)
       {
                Counter = 0;
                for(n = i + 1; NewTFBar == 0 AND n + fvb < BarCount-1; n++)
                        Counter++;
                x2 = GfxConvertBarToPixelX(i + Counter) * NewTFBar + 1 + Adjust;
       }

if(TFBarIndex == TFLastBarIndex)
        x2 = GfxConvertBarToPixelX(i + TFMinutes - 1) * NewTFBar + 1 +
Adjust;

   y1 = GfxConvertValueToPixelY(CandleTop);
   y2 = GfxConvertValueToPixelY(CandleBottom);
   yH = GfxConvertValueToPixelY(TFHigh);
   yL = GfxConvertValueToPixelY(TFLow);

   // Candle Body:
   GfxSelectPen(TFLineColor, 0);
   FillColor = IIf(TFOpen < TFClose, TFUpBarColor,
TFDnBarColor);
   GfxSelectSolidBrush(FillColor);
   if(y1 == y2){y1 = y1 - Adjust; y2 = y2 + Adjust;
GfxSelectSolidBrush(TFLineColor);}
   if(x1 > 0){
   GfxRectangle( x1, y1, x2, y2);
   // Candle High and Low:
   GfxSelectPen(TFLineColor, 2);
   GfxMoveTo(x2+(x1-x2)/2, y1);
   GfxLineTo(x2+(x1-x2)/2, yH);
   GfxMoveTo(x2+(x1-x2)/2, y2);
   GfxLineTo(x2+(x1-x2)/2, yL);
   RequestTimedRefresh(0);
        }
}
}
_SECTION_END();

參考看看了~~ {:9_582:}{:9_580:}

unbattle 發表於 11-8-13 15:32

論壇上有寫這個需要5.2以上版本
晚上去國外偷渡5.3的來用用看

感謝

usana642 發表於 11-8-15 19:39

參考看看,謝謝分享

Speculator168 發表於 11-8-31 00:05

回復 1# unbattle


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

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

感謝您 ^_^ {:7_523:}

sunnyhu 發表於 11-9-4 03:08

謝謝分享這麼有用的技巧 !

hsiao13 發表於 13-6-20 19:30

如果把這個要用於日線與週線上是不是可以?
若是要改要如何改?
謝謝告知的大大!

Rich-888 發表於 13-6-23 19:31

kilroy 發表於 11-8-13 14:28 static/image/common/back.gif
大大~ 這類的還不少喔

1K in 5K


學習~

感謝大大分享!!

{:4_81:}

頁: [1]
查看完整版本: 不同週期的同步