Hàm vẽ đồ thị trong Amibroker: Plot
Cú pháp:
Plot( Array, name, color, style=styleline, minvalue = {empty}, maxvalue = {empty}, XShift = 0, Zorder = 0, width = 1 );
array – mảng giá trị để vẽ
name – đặt tên cho đồ thị
color – màu vẽ
style – kiểu vẽ biểu đồ
- styleLine : đường kẻ liền
- styleHistogram : Biểu đồ tần suất
- styleThick : đường kẻ đậm
- styleDots : đường kẻ chấm
- styleDashed : đường kẻ gạch đứt
- styleCandle : nến
- styleBar : bar
Ví dụ: Vẽ biểu đồ đường giá đóng cửa và đường MA
Plot(Close,"Close",colorBlack,styleCandle);
Plot(MA(Close,20), "MA20", colorRed, styleLine, Null, Null, 10 );
Kết quả:
Ngoài vẽ đồ thị trong Amibroker còn cung cấp hàm vẽ chữ, biểu tượng để
Hàm vẽ chữ trong Amibroker: PlotText
Cú pháp:
PlotText( ”text”, x, y, color, bkcolor = colorDefault, yoffset = 0 )
x – toạ độ trục hoành (thời gian)
y – toạ độ trục tung (giá)
color: màu chữ
bkcolor: màu nền
Ví dụ:
Vẽ chữ Mua khi giá đóng cửa cắt lên MA20 và chữ Bán khi giá đóng cửa cắt xuống MA20
Plot(Close,"Close",colorBlack,styleCandle);
Plot(MA(Close,20), "MA20", colorRed, styleLine, Null, Null, 10 );
Buy= Cross(Close, MA(Close,20 ) );
Sell= Cross(MA(Close,20 ),Close );
dist = 1.5*ATR(10); //lay khoang cach
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] ) PlotText( "Mua " + C[i], i, L[i]-dist[i], colorGreen, colorYellow );
if( Sell[i] ) PlotText( "Ba'n " + C[i], i, H[i]+dist[i], colorRed, colorYellow );
}
Hàm vẽ biểu tượng trong Amibroker: PlotShapes
Cú pháp:
PlotShapes( shape, color, layer = 0, yposition = graph0, offset = -12, XShift = 0 );
shape: Hình dạng
shapeUpArrow, shapeDownArrow, shapeHollowUpArrow, shapeHollowDownArrow, shapeSmallUpTriangle, shapeSmallDownTriangle, shapeHollowSmallUpTriangle, shapeHollowSmallDownTriangle, shapeUpTriangle, shapeDownTriangle, shapeHollowUpTriangle, shapeHollowDownTriangle, shapeSmallSquare, shapeHollowSmallSquare, shapeSquare, shapeHollowSquare, shapeSmallCircle, shapeHollowSmallCircle, shapeCircle, shapeHollowCircle, shapeStar, shapeHollowStar, shapeDigit0, shapeDigit1, shapeDigit2, shapeDigit3, shapeDigit4, shapeDigit5, shapeDigit6, shapeDigit7, shapeDigit8, shapeDigit9
color: Màu sắc
Ví dụ: cùng ví dụ trên, thay vào đó ta vẽ mũi tên lên cho điểm mua, mũi tên xuống cho điểm bán
Plot(Close,"Close",colorBlack,styleCandle);
Plot(MA(Close,20), "MA20", colorRed, styleLine, Null, Null, 10 );
Buy= Cross(Close, MA(Close,20 ) );
Sell= Cross(MA(Close,20 ),Close );
dist = 1.5*ATR(10); //lay khoang cach
PlotShapes( IIf(Buy,shapeUpArrow,IIf(Sell,shapeDownArrow,shapeNone)), IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, L-0.5*dist, H+0.5*dist));
hoặc
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, L-0.5*dist, H+0.5*dist));