Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
Find Out More Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

MACD Multiple Time Frame Exploration for Amibroker (AFL)

Rating:
4 / 5 (Votes 3)
Tags:
amibroker, osicllator, exploration

This is an exploration formula for when the MACD indicator crosses it’s signal line in many different time frames. Daily, weekly, monthly and quarterly are supported.

Indicator / Formula

Copy & Paste Friendly
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//********************************************************** MACD DAILY, WEEKLY, MONTHLY & QUARTERLY ***************************************************
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_SECTION_BEGIN("Daily");
TimeFrameSet(inDaily);
MACD_d=MACD(12, 26);
Signal_d=Signal(12, 26, 9);
Ind_day = WriteIf(Cross(MACD_d, Signal_d),"1.C.OverUp", WriteIf(Cross(Signal_d, MACD_d),"3.C.OverDown", WriteIf(MACD_d >= Signal_d,"2.Up", WriteIf(Signal_d > MACD_d,"4.Down","5.Neutral"))));
Ind_day_cColor = IIf(Cross(MACD_d, Signal_d), colorBrightGreen, IIf(Cross(Signal_d, MACD_d), colorRed,IIf(MACD_d >= Signal_d, colorGreen, IIf(Signal_d > MACD_d, colorDarkRed,colorDefault))));
AddTextColumn(Ind_day,"Day        ", 1, colorDefault, Ind_day_cColor); 
TimeFrameRestore();
_SECTION_END();

_SECTION_BEGIN("Weekly");
TimeFrameSet(inWeekly);
MACD_w=MACD(12, 26);
Signal_w=Signal(12, 26, 9);
Ind_week = WriteIf(Cross(MACD_w, Signal_w),"1.C.OverUp", WriteIf(Cross(Signal_w, MACD_w),"3.C.OverDown", WriteIf(MACD_w >= Signal_w,"2.Up", WriteIf(Signal_w > MACD_w,"4.Down","5.Neutral"))));
Ind_week_cColor = IIf(Cross(MACD_w, Signal_w), colorBrightGreen, IIf(Cross(Signal_w, MACD_w), colorRed,IIf(MACD_w >= Signal_w, colorGreen, IIf(Signal_w > MACD_w, colorDarkRed,colorDefault))));
AddTextColumn(Ind_week,"Week        ", 1, colorDefault, Ind_week_cColor); 
TimeFrameRestore();
_SECTION_END();


_SECTION_BEGIN("Monthly");
TimeFrameSet(inmonthly);
MACD_m=MACD(12, 26);
Signal_m=Signal(12, 26, 9);
Ind_month = WriteIf(Cross(MACD_m, Signal_m),"1.C.OverUp", WriteIf(Cross(Signal_m, MACD_m),"3.C.OverDown", WriteIf(MACD_m >= Signal_m,"2.Up", WriteIf(Signal_m > MACD_m,"4.Down","5.Neutral"))));
Ind_month_cColor = IIf(Cross(MACD_m, Signal_m), colorBrightGreen, IIf(Cross(Signal_m, MACD_m), colorRed,IIf(MACD_m >= Signal_m, colorGreen, IIf(Signal_m > MACD_m, colorDarkRed,colorDefault))));
AddTextColumn(Ind_month,"Month        ", 1, colorDefault, Ind_month_cColor); 
TimeFrameRestore();
_SECTION_END();

_SECTION_BEGIN("Quarterly");
TimeFrameSet(inquarterly);
MACD_q=MACD(12, 26);
Signal_q=Signal(12, 26, 9);
Ind_quarter = WriteIf(Cross(MACD_q, Signal_q),"1.C.OverUp", WriteIf(Cross(Signal_q, MACD_q),"3.C.OverDown", WriteIf(MACD_q >= Signal_q,"2.Up", WriteIf(Signal_q > MACD_q,"4.Down","5.Neutral"))));
Ind_quarter_cColor = IIf(Cross(MACD_q, Signal_q), colorBrightGreen, IIf(Cross(Signal_q, MACD_q), colorRed,IIf(MACD_q >= Signal_q, colorGreen, IIf(Signal_q > MACD_q, colorDarkRed,colorDefault))));
AddTextColumn(Ind_quarter,"Quarterly    ", 1, colorDefault, Ind_quarter_cColor); 
TimeFrameRestore();
_SECTION_END();


macdtot=
IIf(MACD_d>=Signal_d, 1, 0)+
IIf(MACD_w>=Signal_w, 10, 0)+
IIf(MACD_m>=Signal_m, 100, 0)+
IIf(MACD_q>=Signal_q, 1000, 0);
AddColumn (macdtot, "MACDTotal", 1, colorDefault, colorDefault);

macdcont=
IIf(MACD_d>=Signal_d, 1, 0)+
IIf(MACD_w>=Signal_w, 1, 0)+
IIf(MACD_m>=Signal_m, 1, 0)+
IIf(MACD_q>=Signal_q, 1, 0);

AddColumn (macdcont, "MACDCount", 1, colorDefault, colorDefault);

Filter = 1;

7 comments

1. bohaneen11

Version 6.02 does not work

2. administrator

It has been fixed.

3. bohaneen11

The equation has been fixed Thank you

4. Suseda

Hi Mohangbox,

If I need to add Intraday MACD (5, 15 minutes, Hourly) in the indicator.
Please kindly to inform how to write?
Thanks much

5. Suseda

Hi All,

I am a new AFL programmer.
Somebody can help me If I need to add Intraday MACD (5, 15 minutes, 2 Hours) in the indicator.
Please kindly to inform how to write?
I got error message for this

_SECTION_BEGIN("2Hours");
TimeFrameSet(in2hour);
MACD_2h=MACD(12, 26);
Signal_2h=Signal(12, 26, 9);
Ind_2hour = WriteIf(Cross(MACD_2h, Signal_2h),"1.C.OverUp", WriteIf(Cross(Signal_2h, MACD_2h),"3.C.OverDown", WriteIf(MACD_2h >= Signal_2h,"2.Up", WriteIf(Signal_2h > MACD_2h,"4.Down","5.Neutral"))));
Ind_2hour_cColor = IIf(Cross(MACD_2h, Signal_2h), colorBrightGreen, IIf(Cross(Signal_2h, MACD_2h), colorRed,IIf(MACD_2h >= Signal_2h, colorGreen, IIf(Signal_2h > MACD_2h, colorDarkRed,colorDefault))));
AddTextColumn(Ind_2Hour,"2 Hours        ", 1, colorDefault, Ind_2hour_cColor); 
TimeFrameRestore();
_SECTION_END();

Thanks much

6. anand_priy

not working on 6.2 V

7. administrator

Was working fine last time I tested in Amibroker 6.2

Leave Comment

Please login here to leave a comment.

Back