I have a little problem.. These codes do not produce the same results/values on a chart? I'm doing something wrong with my loop???

Code: Select all

`Inputs:`

Series ( Close );

Variables:

Avg1 ( 1 ),

Avg2 ( 2 ),

Avg3 ( 3 ),

Avg4 ( 4 ),

Avg5 ( 5 ),

Avg6 ( 6 ),

Avg7 ( 7 ),

Avg8 ( 8 ),

Avg9 ( 9 ),

Avg10 ( 10 ),

Avg11 ( 11 ),

Avg12 ( 12 ),

Avg13 ( 13 ),

Avg14 ( 14 ),

Avg15 ( 15 ),

Avg16 ( 16 ),

Avg17 ( 17 ),

Avg18 ( 18 ),

Avg19 ( 19 ),

Avg20 ( 20 );

Avg1 = XAverage(Series, 1);

Avg2 = XAverage(Series, 2);

Avg3 = XAverage(Series, 3);

Avg4 = XAverage(Series, 4);

Avg5 = XAverage(Series, 5);

Avg6 = XAverage(Series, 6);

Avg7 = XAverage(Series, 7);

Avg8 = XAverage(Series, 8);

Avg9 = XAverage(Series, 9);

Avg10 = XAverage(Series, 10);

Avg11 = XAverage(Series, 11);

Avg12 = XAverage(Series, 12);

Avg13 = XAverage(Series, 13);

Avg14 = XAverage(Series, 14);

Avg15 = XAverage(Series, 15);

Avg16 = XAverage(Series, 16);

Avg17 = XAverage(Series, 17);

Avg18 = XAverage(Series, 18);

Avg19 = XAverage(Series, 19);

Avg20 = XAverage(Series, 20);

Plot1(Avg1, "Avg1");

Plot2(Avg2, "Avg2");

Plot3(Avg3, "Avg3");

Plot4(Avg4, "Avg4");

Plot5(Avg5, "Avg5");

Plot6(Avg6, "Avg6");

Plot7(Avg7, "Avg7");

Plot8(Avg8, "Avg8");

Plot9(Avg9, "Avg9");

Plot10(Avg10, "Avg10");

Plot11(Avg11, "Avg11");

Plot12(Avg12, "Avg12");

Plot13(Avg13, "Avg13");

Plot14(Avg14, "Avg14");

Plot15(Avg15, "Avg15");

Plot16(Avg16, "Avg16");

Plot17(Avg17, "Avg17");

Plot18(Avg18, "Avg18");

Plot19(Avg19, "Avg19");

Plot20(Avg20, "Avg20");

Code: Select all

`Inputs:`

Series ( Close );

Variables:

Index ( 0 ),

ShortColor ( Green ),

LongColor ( Red );

Arrays:

AvgArr[20]( 0 ),

ColorArr[20]( 0 );

For Index = 1 to 20

Begin

AvgArr[Index] = XAverage(Series, Index);

ColorArr[Index] = GradientColor(Index, 1, 20, ShortColor, LongColor);

End ;

Plot1(AvgArr[1], "AvgArr[1]", ColorArr[1]);

Plot2(AvgArr[2], "AvgArr[2]", ColorArr[2]);

Plot3(AvgArr[3], "AvgArr[3]", ColorArr[3]);

Plot4(AvgArr[4], "AvgArr[4]", ColorArr[4]);

Plot5(AvgArr[5], "AvgArr[5]", ColorArr[5]);

Plot6(AvgArr[6], "AvgArr[6]", ColorArr[6]);

Plot7(AvgArr[7], "AvgArr[7]", ColorArr[7]);

Plot8(AvgArr[8], "AvgArr[8]", ColorArr[8]);

Plot9(AvgArr[9], "AvgArr[9]", ColorArr[9]);

Plot10(AvgArr[10], "AvgArr[10]", ColorArr[10]);

Plot11(AvgArr[11], "AvgArr[11]", ColorArr[11]);

Plot12(AvgArr[12], "AvgArr[12]", ColorArr[12]);

Plot13(AvgArr[13], "AvgArr[13]", ColorArr[13]);

Plot14(AvgArr[14], "AvgArr[14]", ColorArr[14]);

Plot15(AvgArr[15], "AvgArr[15]", ColorArr[15]);

Plot16(AvgArr[16], "AvgArr[16]", ColorArr[16]);

Plot17(AvgArr[17], "AvgArr[17]", ColorArr[17]);

Plot18(AvgArr[18], "AvgArr[18]", ColorArr[18]);

Plot19(AvgArr[19], "AvgArr[19]", ColorArr[19]);

Plot20(AvgArr[20], "AvgArr[20]", ColorArr[20]);