Track indicator performance

Questions about MultiCharts and user contributed studies.
waveslider
Posts: 222
Joined: 16 Oct 2011
Has thanked: 66 times
Been thanked: 20 times

Track indicator performance

Postby waveslider » 26 Apr 2016

Hello -

I am attempting to create an indicator that tracks the average price movement for 10 bars after an indicator turn.
The following code uses the example of a bullish turn.
An array is created for each bar following the signal bar, then the average of each array is generated.

The results are unexpected. I have set the array length (M) to one to see if price movement aligns with the indicator and it does not. Hopefully some fresh eyes will help!
Thanks

Code: Select all

inputs:m(20);

var:ind(0),result(0);
var: a1(0),a2(0),a3(0),a4(0),a5(0),a6(0),a7(0),a8(0),a9(0),a0(0);

array:
r9[](0),
r8[](0),
r7[](0),
r6[](0),
r5[](0),
r4[](0),
r3[](0),
r2[](0),
r1[](0),
r0[](0);

once begin
Array_setmaxindex(r9,m);
Array_setmaxindex(r8,m);
Array_setmaxindex(r7,m);
Array_setmaxindex(r6,m);
Array_setmaxindex(r5,m);
Array_setmaxindex(r4,m);
Array_setmaxindex(r3,m);
Array_setmaxindex(r2,m);
Array_setmaxindex(r1,m);
Array_setmaxindex(r0,m);
end;

ind=cci(5);

if ind[10]<ind[11] and ind[10]<ind[9]
then begin

//Shift array values up one slot
array_copy(r9, 2, r9, 1, m-1);
array_copy(r8, 2, r8, 1, m-1);
array_copy(r7, 2, r7, 1, m-1);
array_copy(r6, 2, r6, 1, m-1);
array_copy(r5, 2, r5, 1, m-1);
array_copy(r4, 2, r4, 1, m-1);
array_copy(r3, 2, r3, 1, m-1);
array_copy(r2, 2, r2, 1, m-1);
array_copy(r1, 2, r1, 1, m-1);
array_copy(r0, 2, r0, 1, m-1);

r9[m]=c[9]-c[10];
r8[m]=c[8]-c[10];
r7[m]=c[7]-c[10];
r6[m]=c[6]-c[10];
r5[m]=c[5]-c[10];
r4[m]=c[4]-c[10];
r3[m]=c[3]-c[10];
r2[m]=c[2]-c[10];
r1[m]=c[1]-c[10];
r0[m]=c[0]-c[10];

a9=AverageArray(r9,m);
a8=AverageArray(r8,m);
a7=AverageArray(r7,m);
a6=AverageArray(r6,m);
a5=AverageArray(r5,m);
a4=AverageArray(r4,m);
a3=AverageArray(r3,m);
a2=AverageArray(r2,m);
a1=AverageArray(r1,m);
a0=AverageArray(r0,m);

end;

if LastBarOnChart=true then begin

plot1[10](a9);
plot2[9](a8);
plot3[8](a7);
plot4[7](a6);
plot5[6](a5);
plot6[5](a4);
plot7[4](a3);
plot8[3](a2);
plot9[2](a1);
plot10[1](a0);

end;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Track indicator performance

Postby TJ » 26 Apr 2016

Hello -

I am attempting to create an indicator that tracks the average price movement for 10 bars after an indicator turn.
The following code uses the example of a bullish turn.
An array is created for each bar following the signal bar, then the average of each array is generated.

The results are unexpected. I have set the array length (M) to one to see if price movement aligns with the indicator and it does not. Hopefully some fresh eyes will help!
Thanks
Not sure what you want to do.

Please make a mock up chart.

maybe a table to illustrate how the numbers should behave?

waveslider
Posts: 222
Joined: 16 Oct 2011
Has thanked: 66 times
Been thanked: 20 times

Re: Track indicator performance

Postby waveslider » 26 Apr 2016

Thanks for looking TJ, it looks like it is actually doing what it should. I was just hoping someone could take a look at the code and have an error jump out at them - or maybe suggest a better way to approach the issue.


Return to “MultiCharts”