PlotXX - Plotting values from an array in a loop?

Questions about MultiCharts and user contributed studies.
lantama
Posts: 96
Joined: 20 Apr 2008
Has thanked: 5 times
Been thanked: 5 times

PlotXX - Plotting values from an array in a loop?

Postby lantama » 16 Mar 2010

Hi, I have an Indicator with an array M of stop levels. I want to plot them in the chart. One way would be:

If M=1 then Plot1(LongStop[M],"Long 1");
If M=2 then Plot2(LongStop[M],"Long 2");
If M=3 then Plot3(LongStop[M],"Long 3");
etc...

However, more easy & smooth would be something like......

For M=1 to MAXNUMBER begin
Plot[M](LongStop[M],"Long "NumtoStr(M,0));
end;

..but this is not working and i found no other way...

Any help appreciated.

Cheers
lantama

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

Postby TJ » 16 Mar 2010

this will work not plot.
the number behind the "plot" is not a variable.


For M=1 to MAXNUMBER begin
Plot[M](LongStop[M],"Long "NumtoStr(M,0));
end;

lantama
Posts: 96
Joined: 20 Apr 2008
Has thanked: 5 times
Been thanked: 5 times

Postby lantama » 16 Mar 2010

Hi TJ
Yes, I know. But is there a solution?

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

Postby TJ » 16 Mar 2010

each plot statement can only draw ONE point on the same bar.

if you want multiple points, you have to make multiple plot statements.


a loop can get a plot statement to draw multiple points on multiple bars,
but not multiple points on the same bar.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Postby SP » 16 Mar 2010

I use arrays and TL, maybe you can adapt it for your code.

Code: Select all

inputs: History (false);
vars: count (0);
arrays:TLLongStop_Array[6](0) ;{Single Dimension Dynamic Array}


FOR count = 5 DOWNTO 0
BEGIN
if TLLongStop_Array[count ] >= 0 then
BEGIN
condition1 = History;
if condition1 then
BEGIN
TL_SetEnd( TLLongStop_Array[count ] , Date, Time, TL_GetValue( TLLongStop_Array[count ] , Date, Time ) ) ;
TL_SetExtRight( TLLongStop_Array[count ] , False ) ;
END
else if History = False then TL_Delete( TLLongStop_Array[count ] ) ;
END ;

TLLongStop_Array[count ] = TL_New_s(MYDATE[count ],MYtime[count ],LongStop[count ],Date,Time_s,LongStop[count ]);


TL_SetColor (TLLongStop_Array[count ],HiColor);
TL_SetStyle (TLLongStop_Array[count ],HiLoLineStyle);
TL_SetExtLeft (TLLongStop_Array[count ],False);
TL_SetExtRight (TLLongStop_Array[count ],False );
TL_SetSize (TLLongStop_Array[count ],4);
END; //count

HummerH1
Posts: 66
Joined: 13 Sep 2011
Has thanked: 6 times
Been thanked: 1 time

Re: PlotXX - Plotting values from an array in a loop?

Postby HummerH1 » 16 Dec 2011

I am also trying to do that.
I have a dynamic array with N lines to plot.

I cannot use the same "plotX" for all of them, so I wonder if there's a way to call another one for each iteration, and this inside the loop.

sort of :

Code: Select all

Variables : i(0),MaxIndex(0),strTemp("");
Array: MyArray[](0);

....

For i=0 to MaxIndex
begin
strTemp = "Plot" + NumToStr(i,0);
.... and then execute the function strTemp to plot MyArray(i)
end;
I used to develop with a language that can do that. So maybe there's a similar way to do that? or any way at all?


Thanks a lot


Return to “MultiCharts”