Background Colour with Buy Signal

Hi, I need a afl code that change the background colour if in my system appears a buy signal .

Best Regards

That's great but what is preventing you from doing that?
Check out this page.

1 Like

Page cannot be opened?. Thanks

This AFL cannot change automatically, can you please help :pray:. Thanks

_SECTION_BEGIN("Change Color Baground");

Plot(C,"Price", colorBlack, styleCandle );
Plot(MA(C,50),"MA50", colorBlue, styleThick );

Buy=Cross( C, MA(C,50 ) );
Sell= Cross( MA( C, 50 ), C );

 if(SelectedValue(Buy))
{
    StaticVarSet( "tmp", 1 );
    SetChartBkColor(colorPaleGreen);
}
if(SelectedValue(Sell))
{
    StaticVarSet( "tmp", 0 );
    SetChartBkColor(colorPink);
}
if(StaticVarGet("tmp")==1)
{
    SetChartBkColor(colorPaleGreen);
    SetChartBkColor(colorLime );
    SetChartBkGradientFill(colorLime,colorWhite );
}
else
{
    SetChartBkColor(colorPink);
    SetChartBkColor(ParamColor("Outer Panel",colorOrange ));
    SetChartBkGradientFill(colorPink,colorWhite );
} 

_SECTION_END();

Hello, can anyone fix this AFL color change background atthis AFL please. @Beppe, @Fxshrat or others ? . Thank you

Please don't beg for responses.

Simply use flip and IIf() functions.

_SECTION_BEGIN("Change Color Baground");
my_ma = MA(C,50);
Plot(C,"Price", colorBlack, styleCandle );
Plot(my_ma,"MA50", colorBlue, styleThick );

Buy=Cross( C,  my_ma );
Sell= Cross( my_ma, C );

intrade = Flip(Buy,Sell);
color1 = IIf(intrade, colorPaleGreen, colorPink);
color2 = IIf(intrade, colorLime, colorOrange);

SetChartBkColor(SelectedValue(color1) );
SetChartBkGradientFill(SelectedValue(color2),colorWhite );
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow,
            IIf( Buy, colorGreen, colorRed ), 0,
            IIf( Buy, L, H ) );
_SECTION_END();

8

9 Likes

Thank you Sir for you response

1 Like