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 ....
For Portfolio Manager Click 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)

4 / 5 (Votes 3)
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 ***************************************************
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); 

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); 

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); 

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); 

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);

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;


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

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); 

Thanks much

6. anand_priy

not working on 6.2 V

7. administrator

Was working fine last time I tested in Amibroker 6.2

8. neurotic

This is perfect. can you make another one exactly like this but add STOCHASTIC daily weekly monthly? thanks

9. mohangbox

Hi All,
The above code should work all Amibroker tool.
Most of them tried for Intraday like 5mins 15mins horuly, You can change




I hope this is helpful your questions.

10. mohangbox

Can any one help me for Intraday data for Amibroker? Did we have any DLL plugin to get intraday data? I will share more Intraday code once validated with Intraday data. For sharing the info or clarifications to Thanks

11. Suseda

Thank you for your answer Mr Mohangbox
But i still got difficult for 4 Hours MAcd.
It can not work.
Please could you fixed the problem.
Here my code for $ Hours.

MACD_4h=MACD(12, 26);
Signal_4h=Signal(12, 26, 9);
Ind_4hours = WriteIf(Cross(MACD_4h, Signal_4h),"1.C.OverUp", WriteIf(Cross(Signal_4h, MACD_4h),"3.C.OverDown", WriteIf(MACD_4h >= Signal_4h,"2.Up", WriteIf(Signal_4h > MACD_4h,"4.Down","5.Neutral"))));
Ind_4hours_cColor = IIf(Cross(MACD_4h, Signal_4h), colorBrightGreen, IIf(Cross(Signal_4h, MACD_4h), colorRed,IIf(MACD_4h >= Signal_4h, colorGreen, IIf(Signal_4h > MACD_4h, colorDarkRed,colorDefault))));
AddTextColumn(Ind_4hours,"4 Hours        ", 1, colorDefault, Ind_4hours_cColor); 

Thank you before

12. Suseda

SOLVED, Thanks

13. pankajb

Hi All,

I am a new to AFL programming.
Can somebody can help me to add Intraday MACD (15, 1Hour, 3 Hours) in the indicator.
I have tried below cod but its not working,

MACD_m15=MACD(24, 30);
Signal_m15=Signal(24, 30, 6);
Ind_m15 = WriteIf(Cross(MACD_m15, Signal_m15),"1.C.OverUp", WriteIf(Cross(Signal_m15, MACD_m15),"3.C.OverDown", WriteIf(MACD_m15 >= Signal_m15,"2.Up", WriteIf(Signal_m15 > MACD_m15,"4.Down","5.Neutral"))));
Ind_m15_cColor = IIf(Cross(MACD_m15, Signal_m15), colorBrightGreen, IIf(Cross(Signal_m15, MACD_m15), colorRed,IIf(MACD_m15 >= Signal_m15, colorGreen, IIf(Signal_m15 > MACD_m15, colorDarkRed,colorDefault))));
AddTextColumn(Ind_m15,"15Minute        ", 1, colorDefault, Ind_m15_cColor); 

MACD_h1=MACD(24, 30);
Signal_h1=Signal(24, 30, 6);
Ind_h1 = WriteIf(Cross(MACD_h1, Signal_h1),"1.C.OverUp", WriteIf(Cross(Signal_h1,MACD_h1),"3.C.OverDown", WriteIf(MACD_h1 >= Signal_h1,"2.Up", WriteIf(Signal_h1 > MACD_h1,"4.Down","5.Neutral"))));
Ind_h1_cColor = IIf(Cross(MACD_h1, Signal_h1), colorBrightGreen, IIf(Cross(Signal_h1, MACD_h1), colorRed,IIf(MACD_h1 >= Signal_h1, colorGreen, IIf(Signal_h1 > MACD_h1, colorDarkRed,colorDefault))));
AddTextColumn(Ind_h1,"Hourly        ", 1, colorDefault, Ind_h1_cColor); 

MACD_h3=MACD(24, 30);
Signal_h3=Signal(24, 30, 6);
Ind_h3 = WriteIf(Cross(MACD_h3, Signal_h3),"1.C.OverUp", WriteIf(Cross(Signal_h3,MACD_h3),"3.C.OverDown", WriteIf(MACD_h3 >= Signal_h3,"2.Up", WriteIf(Signal_h3 > MACD_h3,"4.Down","5.Neutral"))));
Ind_h3_cColor = IIf(Cross(MACD_h3, Signal_h3), colorBrightGreen, IIf(Cross(Signal_h3, MACD_h3), colorRed,IIf(MACD_h3 >= Signal_h3, colorGreen, IIf(Signal_h3 > MACD_h3, colorDarkRed,colorDefault))));
AddTextColumn(Ind_h3,"3Hours        ", 1, colorDefault, Ind_h3_cColor); 


14. mohangbox

Someone copy & Paste it from here to as same code…..

Leave Comment

Please login here to leave a comment.