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
dynamic number of plots in indicators
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 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]
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.
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!)
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!)
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
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