Help to understand last bar in PlotOHLC styleCloud

With this formula and results in explore:

S = colorYellow;
S[BarCount - 1] = colorGreen;
S[BarCount - 2] = colorRed;
S[BarCount - 3] = colorGreen;
PlotOHLC( 1, 1, 0, 0, "", S, styleCloud );

AddColumn( BarIndex(), "BarIndex", 1 );
AddColumn( BarCount, "BarCount", 1 );
AddColumn( S, "S", 1 );
Filter = 1;

image
I expect this result:
image

But I get this one:
image

Any clue?

This is the code for plotting the first image:

S = colorYellow;
S[BarCount - 2] = colorGreen;
S[BarCount - 3] = colorRed;
S[BarCount - 4] = colorGreen;
PlotOHLC( 1, 1, 0, 0, "", S, styleCloud );

v6.40.4

In styleCloud, the color[0] is used to paint area between bar 0 and 1, color[1] is used to paint area between bar 1 and 2, and so on, so color[ BarCount -2 ] is used to paint space between bars with indices BarCount-2 and BarCount-1. There is no next bar after BarCount-1 so such color is not used.

To achieve what you want use this code:

S = colorYellow;
S[BarCount - 1] = colorGreen;
S[BarCount - 2] = colorRed;
S[BarCount - 3] = colorGreen;
Plot( 1, "", S, styleArea | styleOwnScale, 0, 1  );
2 Likes

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