I think this code does what you want:
dt = New Table( "testcolors", Add Rows( 15 ),
New Column( "Article", Character, "Nominal",
Set Values( {"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A"}
) ),
New Column( "Item", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] )
),
New Column( "status", Character, "Nominal",
Set Values(
{"red", "red", "red", "green", "green", "red", "red", "red", "red",
"red", "red", "green", "red", "red", "red"}
)
),
// Créez une nouvelle colonne pour l'indicateur
New Column("Indicateur", Character, Nominal)
);
one_color = "xyz";
icolor = 0;
for (i = 1, i <= nrows(dt), i++,
one_color = dt:status[i];
if (one_color == "red",
icolor++;
// else
,
if (icolor >= 5,
dt:Indicateur << Color Cells( "Red", i-1 );
icolor = 0;
// else
,
icolor >= 3,
dt:Indicateur << Color Cells( "Yellow", i-1 );
icolor = 0;
);
);
);
// Handle the last row
if (icolor >= 5,
dt:Indicateur << Color Cells( "Red", i-1 );
// else
,
icolor >= 3,
dt:Indicateur << Color Cells( "Yellow", i-1 );
);