Loop with Plot function

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
Laurent
Posts: 159
Joined: 20 Nov 2010
Location: France
Has thanked: 76 times
Been thanked: 34 times

Loop with Plot function

Postby Laurent » 07 Feb 2012

Is it possible to use the Plot function in a loop?
If yes, how to do it?

For example, I fill an array (Ex: MyArr[200]( 0 )) and I want to plot all the values in it.
How to do it, without using

Plot1(MyArr[1]);
Plot2(MyArr[2]);
Plot3(MyArr[3]);
...

Any ideas?

Best Regards,

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

Re: Loop with Plot function

Postby TJ » 07 Feb 2012

Is it possible to use the Plot function in a loop?
If yes, how to do it?

For example, I fill an array (Ex: MyArr[200]( 0 )) and I want to plot all the values in it.
How to do it, without using

Plot1(MyArr[1]);
Plot2(MyArr[2]);
Plot3(MyArr[3]);
...

Any ideas?

Best Regards,
Can you draw a diagram to illustrate your intention?


notes:

Each PLOT can "draw" one data point per bar.

eg.
PLOT1 can draw a dot at price value 100.
if you want another dot, on the same bar (say, at 101),
you must use another plot (eg PLOT2).

if you have 200 data points in the array that you want to plot on the same bar,
then you must have PLOT1, PLOT2... PLOT200.



if you have 200 data points in the array that you want to plot on the previous 200 bars,
you can try this:

Code: Select all

for value1 = 0 to 200
begin
Plot1[value1]( MyArr[ value1 ] ) ;
end;

Laurent
Posts: 159
Joined: 20 Nov 2010
Location: France
Has thanked: 76 times
Been thanked: 34 times

Re: Loop with Plot function

Postby Laurent » 09 Feb 2012

Thanks a lot for your answer TJ, I have solved my problem, you're always a great help for me!

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

Re: Loop with Plot function

Postby TJ » 09 Feb 2012

Thanks a lot for your answer TJ, I have solved my problem, you're always a great help for me!
You are welcome. I am glad you solved the problem.


Return to “User Contributed Studies and Indicator Library”