Shading using PLOTOHLC

Hi Guys,
I cannot seem to shade all the bars between the top and bottom lines. It will only shade the areas, based on what the current zig is doing. So in this example the zig is down, so all down bars are shaded. I just need all bars shaded, regardless of zig. I know it has to do with the loop, but cannot seem to fix this.

Example 1.

Per = Param("Period", 5, .1, 20, 1);
Period = Param("Look back", 10, 1, BarCount-1);
ZigP = Zig(C, per);

Plot(C, "", IIf(O>=C, colorDarkRed, colorDarkGreen), ParamStyle("Price Style",styleBar,maskPrice));
Plot(ZigP, "Zig", colorGold, styleThick);

for(i=2; i<=Period; i++)
{
ys0=LastValue(Trough(ZigP,per,i)); 
ys1=LastValue(Trough(ZigP,per,i-1)); 
xs0=BarCount - 1 - LastValue(TroughBars(ZigP,per,i)); 
xs1=BarCount - 1 - LastValue(TroughBars(ZigP,per,i-1)); 

sup = LineArray( xs0, ys0, xs1, ys1, 0 ); 
Plot( sup, "", colorRed,0,0,0,0,0,6 );

yr0=LastValue(Peak(ZigP, Per, i)); 
yr1=LastValue(Peak(ZigP, Per, i-1)); 
xr0=BarCount - 1 - LastValue(PeakBars(ZigP, Per,i)); 
xr1=BarCount - 1 - LastValue(PeakBars(ZigP, Per,i-1)); 

res = LineArray( xr0, yr0, xr1, yr1, 0 ); 
Plot( res, "", colorBlue,0,0,0,0,0,6 );
PlotOHLC(res,sup,res,sup,"",colorGreen,styleCloud+styleNoLabel,0,0,0,0,0);
 
}
//PlotOHLC(res,sup,res,sup,"",colorGreen,styleCloud+styleNoLabel,0,0,0,0,0);

Example 2.
I was able to shade all bars needed, but now It does not shade between the lines as intended.

Per = Param("Period", 5, .1, 20, 1);
Period = Param("Look back", 10, 1, BarCount-1);

ZigP = Zig(C, Per);

Plot(C, "", IIf(O >= C, colorDarkRed, colorDarkGreen), ParamStyle("Price Style", styleBar, maskPrice));
Plot(ZigP, "Zig", colorGold, styleThick);

resArray = Null;
supArray = Null;

for (i = 2; i <= Period; i++)
{
    ys0 = LastValue(Trough(ZigP, Per, i)); 
    ys1 = LastValue(Trough(ZigP, Per, i-1)); 
    xs0 = BarCount - 1 - LastValue(TroughBars(ZigP, Per, i)); 
    xs1 = BarCount - 1 - LastValue(TroughBars(ZigP, Per, i-1)); 

    sup = LineArray(xs0, ys0, xs1, ys1, 0); 
    Plot(sup, "", colorRed, 0, 0, 0, 0, 0, 6);

    yr0 = LastValue(Peak(ZigP, Per, i)); 
    yr1 = LastValue(Peak(ZigP, Per, i-1)); 
    xr0 = BarCount - 1 - LastValue(PeakBars(ZigP, Per, i)); 
    xr1 = BarCount - 1 - LastValue(PeakBars(ZigP, Per, i-1)); 

    res = LineArray(xr0, yr0, xr1, yr1, 0); 
    Plot(res, "", colorBlue, 0, 0, 0, 0, 0, 6);

    resArray = IIf(i == 2, res, IIf(i == Period, LineArray(xr0, yr0, BarCount-1, yr0, 0), resArray));
    supArray = IIf(i == 2, sup, IIf(i == Period, LineArray(xs0, ys0, BarCount-1, ys0, 0), supArray));
}

PlotOHLC(supArray, resArray, supArray, resArray, "", colorGreen, styleCloud+styleNoLabel);

Thanks very much for any help on this, in advance.

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