How to blink only Green Bar comming in the following AFL

SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

// Supertrend - Translated from Kolier MQ4
// see: http://kolier.li/indicator/kolier-supertrend-indi
// translation in Amibroker AFL code by E.M.Pottasch, 2011

procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
{
global buffer_line_down;
global buffer_line_up;
buffer_line_down = Null;
buffer_line_up = Null;

PHASE_NONE = 0;
PHASE_BUY = 1;
PHASE_SELL = -1;

phase=PHASE_NONE;
band_upper = 0;band_lower = 0;

for(i = ATR_Period + 1; i < BarCount; i++)
{
band_upper = CalcPrice[i] + ATR_Multiplier * tr[i];
band_lower = CalcPrice[i] - ATR_Multiplier * tr[i];

if(phase==PHASE_NONE)
{
    buffer_line_up[i] = CalcPrice[i];
    buffer_line_down[i] = CalcPrice[i];
}
if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1])) 
{
    phase = PHASE_BUY;
    buffer_line_up[i] = band_lower;
    buffer_line_up[i-1] = buffer_line_down[i-1];
}
if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
{
    phase = PHASE_SELL;
    buffer_line_down[i] = band_upper;
    buffer_line_down[i-1] = buffer_line_up[i-1];
}   
if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
{
    if(band_lower>buffer_line_up[i-1]) 
    {
        buffer_line_up[i] = band_lower;
    }
    else
    {
        buffer_line_up[i] = buffer_line_up[i-1];
    }
}
if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
{
    if(band_upper<buffer_line_down[i-1])
    {
        buffer_line_down[i] = band_upper;
    }
    else
    {
        buffer_line_down[i] = buffer_line_down[i-1];
    }
}

}
}

SetBarsRequired(sbrAll,sbrAll);

TrendMode = ParamToggle("TrendMode","Off|On",1);
ATR_Multiplier = Param("ATR_Multiplier",2,0.1,10,0.1);
ATR_Period = Param( "ATR_Period",5,1,20,1);
tr = ATR(ATR_Period);

CalcPrice = (H+L)/2;
calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);

SetChartOptions(0,chartShowDates);
//Plot(C,"C",colorWhite,64);

if ( TrendMode == 1 )
{
Plot( buffer_line_up, "\ntu", ColorRGB( 28, 134, 238 ), styleThick );
Plot( buffer_line_down, " // td", ColorRGB( 205, 51, 51 ), styleThick );

Plot( 4, "", IIf( buffer_line_up, colorBrightGreen, colorBlack ), styleOwnScale | styleArea | styleNoLabel, -0.5, 100 );
Plot( 6, "", IIf( buffer_line_down, colorRed, colorBlack ), styleOwnScale | styleArea | styleNoLabel, -0.5, 100 );

}

//ONLY BOTTAM PART OF TIS SCRREN SHOLD BLINK
//BECAUSE ITS EYE CATCHER FOR ME
// USING ONLY CANDLES OR NO CANDLES SOMETIME
//this code chggested by Chat GPT
// having some error.
//Can some on help in this

if (TrendMode == 1)
{
Plot(buffer_line_down, "\ntd", ColorRGB(205, 51, 51), styleThick);

// Create a variable to toggle the visibility
bool blinkToggle = true;

// Calculate the blinking effect
if (TimeCurrent() % 2 < 1) // Adjust the blinking speed by changing the divisor
{
    blinkToggle = !blinkToggle;
}

// Plot the green area with the blinking effect
Plot(4, "", IIf(blinkToggle, colorBrightGreen, colorBlack), styleOwnScale | styleArea | styleNoLabel, -0.5, 100);
Plot(6, "", IIf(buffer_line_down, colorRed, colorBlack), styleOwnScale | styleArea | styleNoLabel, -0.5, 100);

}

When posting the formula, please make sure that you use Code Tags (using </> code button) as explained here: How to use this site.

Using code button

Code tags are required so formulas can be properly displayed and copied without errors.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.