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);
Need help in plotting an array that I created
- TJ
- Posts: 7746
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2225 times
Re: Need help in plotting an array that I created
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.
- 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
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]);
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;
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]);
Regards,#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
....
Josh