dynamic number of plots in indicators

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

dynamic number of plots in indicators

Postby ts2mc » 22 Jan 2009

hello experts,
within indiciators, you can define your different plots by using
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[i] ?

anyone knows a solution ?

thank you

User avatar
Posts: 6572
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1902 times

Postby TJ » 22 Jan 2009

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.

Posts: 122
Joined: 12 Jan 2009
Been thanked: 1 time

Postby ts2mc » 22 Jan 2009

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
else if ip = 2 then begin
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!)

Posts: 754
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 84 times

Postby janus » 07 Jun 2009

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.

Posts: 2026
Joined: 21 Jul 2007
Has thanked: 174 times
Been thanked: 405 times

Postby bowlesj3 » 07 Jun 2009

This approach is a little shorter. This isn't pure EL but has the basic idea.

Input PlotsWanted;

if PlotsWanted > 0 then
do your plot1;
if PlotsWanted > 1 then
do your plot2;
if PlotsWanted > 2 then
do your plot3;

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 :-)

User avatar
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 12 times

Postby RobotMan » 08 Jun 2009

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".

Return to “MultiCharts”