Skip to main content

Weekly MACD Signal with 5 ROC on Daily Charts for Amibroker (AFL)

ajmal017 over 14 years ago Amibroker (AFL)

  • Rating:
    2 / 5 (Votes 3)
  • Tags:
    oscillator, amibroker

Weekly MACD Signal with 5 ROC on Daily Charts

Add this code to ANY indicator you like. To be used in “Indicator” in AB
This code will approximate A Weekly ROC of MACD ( see seperate code for an
weekly indicator in the AB Files ). There is NO PRESENTATION of A GRAPH.
The results will give a text readout during “Daily” presentation of what the // weekly trend is doing.

Indicator / Formula

Copy & Paste Friendly
/*  Text of Weekly MACD Signal with 5 ROC on Daily Charts 
    INSTRUCTIONS AT END OF CODE  */

weeklyprice=C;
Weekly=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1),WeeklyPrice);

W6ema = EMA(weekly,30);// 6 weeks * 5 days per week
W13ema = EMA(weekly,65);// 13 weeks * 5 days per week
MACDSignal = EMA((W6ema - W13ema),25);// 5 weeks * 5 days per week

ROCMACD = MACDSignal - Ref(MACDSignal,-25);//ROC of MACD Signal

//Cond1 - "V" bottom, start of climb
Cond1 = IIf(ROCMACD > Ref(ROCMACD,-5)  AND Ref(ROCMACD,-5) <= Ref(ROCMACD,-10),1,0);
//Cond2 - "V" top, start of drop
Cond2 = IIf(ROCMACD < Ref(ROCMACD,-5)   AND Ref(ROCMACD,-5) >= Ref(ROCMACD,-10),1,0);
//cond3 - Steady up trend
Cond3 = IIf(ROCMACD> Ref(ROCMACD,-5) AND Ref(ROCMACD,-5) >= Ref(ROCMACD,-10),1,0);
//Cond4 - Steady down trend
Cond4 = IIf(ROCMACD < Ref(ROCMACD,-5) AND Ref(ROCMACD,-5) <= Ref(ROCMACD,-10),1,0);
//Cond5 - no change - flat
Cond5 = IIf(ROCMACD = Ref(ROCMACD,-5) ,1,0);

Title = Title + "        Weekly -"  
 + WriteIf(Cond1," NEW UP TREND  ", WriteIf(Cond2," NEW DOWN TREND   ", WriteIf(Cond3," Trend is Up    ",WriteIf(Cond4,"  Trend is Down    ",WriteIf(Cond5,"    Trend is Flat    ","")))));

//  Add this code to ANY indicator you like.  To be used in "Indicator" in AB
//  This code will approximate A Weekly ROC of MACD ( see seperate code for an
//  weekly indicator in the AB Files ).  There is NO PRESENTATION of A GRAPH.  
//  The results will give a text readout during "Daily" presentation of what the       //  weekly trend is doing.

4 comments

over 14 years ago

AFL NOT WORKING….IN 5.40 AMIBROKER VERSION. ADMIN PL HELP FOR CODING.

3. joeoil
over 14 years ago

In line 22 I think there should be:
Condi5 = IIf(ROCMACD == Ref(ROCMACD,-5) ,1,0);

In line line 24 I think there should be:
Title = Name() + " Weekly -"

Then you will not get an error message.

Leave Comment

Please login here to leave a comment.