Need help in plotting an array that I created

Questions about MultiCharts and user contributed studies.
kentai
Posts: 29
Joined: 02 Jun 2011
Has thanked: 9 times
Been thanked: 1 time

Need help in plotting an array that I created

Postby kentai » 02 Aug 2011

Hi,

I just created an indicator and I tried to incorporate an array in it.

I like to plot this array, but it doesn't seem to work. I need some help

Below is the coding.

Regards,
Ken

input: Field(Close);

var: MA6(0), var0(0), RSIArray(0);

array: Array1[100](0);

MA6 = Xaverage(field,6);

var0 = 0;
For var0 = 0 to 100 begin
Array1[var0] = MA6[var0];
var0= var0+1;
end;

Plot1(Array1);

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

Re: Need help in plotting an array that I created

Postby TJ » 02 Aug 2011

1. Please use

Code: Select all

tag when posting codes. It makes reading easier.

2. Please describe what do you mean by "doesn't seem to work"?
no plot? plot the wrong number? compile error? or something else???
Please copy and paste the error message if there is one.

3. Please post a screen shot if it can help you explain your problem.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Need help in plotting an array that I created

Postby JoshM » 02 Aug 2011

I like to plot this array, but it doesn't seem to work.

[..]

Code: Select all

Plot1(Array1);
Hi Kentai,

You can't plot an array, but you can plot the value at an specific array entry. For example,

Code: Select all

Plot1(Array1[1]);
or
Plot1(Array1[35]);
or
Plot1(Array1[95]);
..would all work, while 'Plot1(Array1);' in effect is saying 'plot the whole array' (all 100 entries), which can't be done in one Plot1. So I don't know what you're trying to achieve, but it probably have to be implemented in another way.

You also can remove the 'var0 = var0 + 1' statement from your loop, since EasyLanguage implicitly adds one to var0 for each loop entry. You can check that for yourself by using the following code:

Code: Select all

if LastBarOnChart_s = True then begin

For var0 = 0 to 100 begin
Print(var0);
end;

end;
Which will print the numbers 0 through 100. Adding your 'var0 = var0 + 1' statement to this code will give the numbers 0 to 100, with a step size of 2 (0, 2, 4, etc).

You could try this code, though the Plot1 statement uses the Array1[1] value, which is probably not what you intended.

Code: Select all

input: Field(Close);

var: MA6(0), var0(0), RSIArray(0);

array: Array1[100](0);

MA6 = Xaverage(field, 6);
var0 = 0;

For var0 = 0 to 100 begin
Array1[var0] = MA6[var0];

if LastBarOnChart_s = True then begin
Print("#", NumToStr(var0, 0), " Array1 value: ", NumToStr(Array1[var0], 4),
" MA6 value: ", NumToStr(MA6[var0], 4));
end;

end;

Plot1(Array1[1]);
The debug gives the following output:
#0 Array1 value: 1.4475 MA6 value: 1.4475
#1 Array1 value: 1.4474 MA6 value: 1.4474
#2 Array1 value: 1.4476 MA6 value: 1.4476
#3 Array1 value: 1.4477 MA6 value: 1.4477
#4 Array1 value: 1.4478 MA6 value: 1.4478
#5 Array1 value: 1.4484 MA6 value: 1.4484
#6 Array1 value: 1.4488 MA6 value: 1.4488
#7 Array1 value: 1.4494 MA6 value: 1.4494
....
Regards,
Josh


Return to “MultiCharts”