Help AFL

#1
Hello,
I need to draw the MACD histogram of 30 minutes in a 5-minute chart. I also need that when the MACD histogram to rise, even when below zero, is of a color and if it is reduced, even if greater than zero is of a different color.
I managed to draw, but I can not succeed with the colors.
Can you help me?. Thank you very much,
Herewith the AFL I've written.

Regards,

_SECTION_BEGIN("MACD");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
TimeFrameSet(in1Minute * 30);
ml30 = MACD (r1, r2);
sl30 = Signal(r1,r2,r3);
rl30= ml30 - sl30;
TimeFrameRestore ();
rl1 = TimeFrameExpand (rl30, in1Minute * 30);
Color13 = IIf (rl1 > Ref ( rl1, -1), colorWhite, colorBlack);
//Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
//Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
Plot( rl1, "MACD Histogram", Color13, styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );

Plot (100, "", IIf( rl1> Ref (rl1, -1), colorPaleGreen, colorPink), styleArea+styleOwnScale, 0, 1);
_SECTION_END();
 

HULK

Active Member
#2
Hello,
I need to draw the MACD histogram of 30 minutes in a 5-minute chart. I also need that when the MACD histogram to rise, even when below zero, is of a color and if it is reduced, even if greater than zero is of a different color.
I managed to draw, but I can not succeed with the colors.
Can you help me?. Thank you very much,
Herewith the AFL I've written.

Regards,

_SECTION_BEGIN("MACD");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
TimeFrameSet(in1Minute * 30);
ml30 = MACD (r1, r2);
sl30 = Signal(r1,r2,r3);
rl30= ml30 - sl30;
TimeFrameRestore ();
rl1 = TimeFrameExpand (rl30, in1Minute * 30);
Color13 = IIf (rl1 > Ref ( rl1, -1), colorWhite, colorBlack);
//Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
//Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
Plot( rl1, "MACD Histogram", Color13, styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );

Plot (100, "", IIf( rl1> Ref (rl1, -1), colorPaleGreen, colorPink), styleArea+styleOwnScale, 0, 1);
_SECTION_END();

Hi jose

Try this i think this is what u are looking for

_SECTION_BEGIN("MACD");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
TimeFrameSet(in1Minute * 30);
ml30 = MACD (r1, r2);
sl30 = Signal(r1,r2,r3);
rl30= ml30 - sl30;
TimeFrameRestore ();
rl1 = TimeFrameExpand (rl30, in1Minute * 30);
Color13 = IIf(rl1>Ref(rl1,-1),IIf(rl1 > 0,27,41),IIf(rl1 > 0,43,32));
//IIf (rl1 > Ref ( rl1, -1), colorWhite, colorBlack);
//Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
//Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
Plot( rl1, "MACD Histogram", Color13, styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );

Plot (100, "", IIf( rl1> Ref (rl1, -1), colorPaleGreen, colorPink), styleArea+styleOwnScale, 0, 1);
_SECTION_END();

HULK
 
#3
Thank you very much for the reply.
Not exactly what I need.
The MACD histogram in 30 minutes in a 5-minute chart is drawn well.
When the MACD histogram in 30 minutes changed its slope, in the 5 minute chart, change the color of the line, but the following lines to return to previous color and do not follow the change of color. That's what I need, once you change the color, this is maintained until a new change of slope and so on. Thank you very much for your time and assistance.

Regards,
 

Similar threads