# dynamic number of plots in indicators

Questions about MultiCharts and user contributed studies.
ts2mc
Posts: 122
Joined: 12 Jan 2009
Been thanked: 1 time

### dynamic number of plots in indicators

hello experts,
within indiciators, you can define your different plots by using
keywords
plot1....plotN
this presumes, that number of plots does not depend on input paramters.

what, if you need a dynamic number of plots, so instead of
plot55 plot[55] or plot ?

anyone knows a solution ?

thank you

TJ
Posts: 7458
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 999 times
Been thanked: 2137 times
the "dynamic" is not in the plotN.

you can have as many plots as you want... (to 99, I think)
the "dynamic" is in the logic that triggers the plot.

[edit: some comments deleted]
Last edited by TJ on 22 Jan 2009, edited 1 time in total.

ts2mc
Posts: 122
Joined: 12 Jan 2009
Been thanked: 1 time
hello,
sorry, but this does not solve my problem.

indicators have input parameters.
i want make the number of plots dependent from
an input parameter (1 <= ip <= 999)

and i want to avoid to code something like

if ip = 1 then begin
Plot1
end
else if ip = 2 then begin
Plot1
Plot2
end
..
and so on
as this would be nonsense.

(i can't belive that MC offsers such a huge number of plots, but does not
allows to refer them by an index -> plot[x], like SetPlotColor[idx] <- allows access to plot by index!)

janus
Posts: 802
Joined: 25 May 2009
Has thanked: 46 times
Been thanked: 94 times
I've just come up with this unfortunate restriction also. It's odd you can use noplot dynamically (eg, noplot(n)). Oh well, I'll just have to use the brute force way.

bowlesj3
Posts: 2148
Joined: 21 Jul 2007
Has thanked: 210 times
Been thanked: 424 times
This approach is a little shorter. This isn't pure EL but has the basic idea.

Input PlotsWanted;

if PlotsWanted > 0 then
if PlotsWanted > 1 then
if PlotsWanted > 2 then

At least the plot statements are not duplicated as much. Here is the thing. It may be longer code but It may not be slower code or at least it won't be noticable. Actually to call a function creates a tiny bit of extra code under the hood called branching and linking which takes a tiny bit of extra time so in theory if your function is really simple and never going to be changed and only called 2 or 3 times it might be better to duplicate the code (neither here nor there). Along this line I have code that has 1 repetition and I put it into functions but there we so many parameters to the function (like about 50 or 60) that it was just a lot easier to change the first one each time and just cut and paste it. I got rid of the function approach. It runs that tiny bit faster as well as saving me a lot of work each time I change it. In order to make that function easier programming wise the variables would need to be such that they could be made public like Microsoft allows which would mean I do not need to string them behind the function. I use to try and get my code super small but don't bother trying so hard any more. I only have to program it once. My main concern is how fast does it run. Related to this topic, I asked for a debugger like the MS-Cobol debugger which is probably the best in the world but each company has limits to how much money it has to do these wonderful things. If it isn't a serious problem for trading I just try to get my mind back to trading A.S.A.P. and clear my head of these distractive wishes.

It is 999 plots. I tried it. Well I skipped a few in between. That would be an interesting chart with 999 actual plots

RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 13 times
Contact:
Maybe you could incorporate: TL_New_Self_s ?

I have heard others use this instead of plots. Plus, you can get a buttload of them on a chart by just issuing a new "ID".