Chỉ báo được xây dựng trên đường trung bình EMA và chỉ báo MACD
Màu đỏ : downtrend
Màu xanh : uptrend
Màu vàng : Sideway
Khi nến đỏ : Xu hướng giảm
Khi nến xanh : Xu hướng tăng
Khi nến vàng : Đi ngang, chưa xác định
Điều kiện :
cond1 = Close > EMA(C, 17) AND MACD() > Signal();
cond2 = Close > EMA(C, 17) AND MACD() < Signal() OR Close < EMA(C, 17) AND MACD() > Signal();
cond3 = Close < EMA(C, 17) AND MACD() < Signal();
Amibroker code :
//Candles or bars colored by trend
//identifying trends with EMA and MACD
cond1 = Close > EMA(C, 17) AND MACD() > Signal();
cond2 = Close > EMA(C, 17) AND MACD() < Signal() OR Close < EMA(C, 17) AND MACD() > Signal();
cond3 = Close < EMA(C, 17) AND MACD() < Signal();
Period = Optimize("Period", 17, 2, 200, 1);
EMACALC = EMA(C, Period);
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
//============== TITLE ==============
_SECTION_BEGIN("Title");
Title = EncodeColor(colorGold)+ "GRAFICO BASICO" + EncodeColor(colorRose)+" (" + Name() + ") " + EncodeColor(colorGold)+ Interval(2) +
" " + Date() +" " +" • Open "+WriteVal(O,1.20)+" • "+"High "+WriteVal(H,1.20)+" • "+"Low "+WriteVal(L,1.20)+" • "+
"Close "+WriteVal(C,1.20)+" • Variaç?o R$ = " +WriteVal(C-Ref(C,-1),1.20,0)+" • Variaç?o % = " +WriteVal((C-Ref(C,-1))*100/Ref(C,-1),1.2)+ "% • Volume = "+ WriteVal(V,1.0);
upbar = COND1;
downbar = COND3;
/* Colourized price bars drawn here */
Graph0 = Close;
Graph0Style = 64;//number 64 = candlestick or 128 = bar;
barcolor = IIf( downbar, 4, IIf( upbar, 5, 42 ) );//number 4 = red, number 5 = green and number 42 = yellow;
Graph0BarColor = ValueWhen( barcolor != 0, barcolor );
// Only allowed in recent Beta
//SetBarFillColor = ValueWhen( barcolor != 0, barcolor );
_SECTION_END();
Plot(EMACALC, "EMACALC", colorWhite, styleLine,0,0,0,0,2);

No comments:
Post a Comment