Hello John
How about a global variable value with a specific name for each study
In an external signal file, use these code to setup global variables
Var: IntVal (0);
IntVal = GVsetNamedInt ("StudyOne", 3); // 3 data series to look for
IntVal = GVsetNamedInt ("StudyTwo", 2); // 2 data series to look for
Fo each specific study, use
Var: HowManyDataSeries (0);
Var: IntVal (0);
HowManyDataSeries = GVGetNamedInt ("StudyTwo",1) // Rem: 1 will be your default value
This is just an exemple.
You could also have an array created using name of study and #data series. When testing, look trough your Array using your study name and get your # of data series to test
Good luck
Martin
Thanks Martin! Very helpful and I've incorporated this solution by setting the GlobalVariables in a separate script.
In solving this problem I came across something else I don't thoroughly understand. According to the help manual (EasyLanguage Essentials), this is a good use of
once:
Code: Select all
Var: Counter(0);
once ( CurrentBar = 1 ) and ( Counter = 0 ) begin
Counter = 1000;
end;
Because there is no need to set the GlobalVariables on each bar and then extract the number of data series (since this will remain constant for each bar), I was thinking about using Once to get better performance. However, this code..
Code: Select all
Var: HowManyDataSeries (0), tmp(""), tmpCounter(0);
Var: IntVal (0);
if CurrentBar = 1 then begin
ClearDebug;
Print("HowManyDataSeries: ", HowManyDataSeries);
end;
// Get number of data series
once (CurrentBar = 1 and HowManyDataSeries = 0) begin
//if CurrentBar = 1 then begin
Print("Getting data series...");
tmp = "StudyTwo";
MyTestFunction2;
if tmp = "StudyOne" then
HowManyDataSeries = GVGetNamedInt("StudyOne", 1)
else if tmp = "StudyTwo" then
HowManyDataSeries = GVGetNamedInt("StudyTwo", 1);
tmpCounter = tmpCounter + 1;
end;
if LastBarOnChart_s = true then begin
Print("Number of data series for this symbol", howManyDataSeries, " number of times set: ", tmpCounter);
end;
Gives the following output:
HowManyDataSeries: 0.00
Number of data series for this symbol 0.00 number of times set: 0.00
Number of data series for this symbol 0.00 number of times set: 0.00
Number of data series for this symbol 0.00 number of times set: 0.00
Number of data series for this symbol 0.00 number of times set: 0.00
Changing the
- once (CurrentBar = 1 and HowManyDataSeries = 0) begin
to another 'once' statement will yield the same results (actually multiple once variations all give the erroneous output displayed above).
Off course, I can use
- if CurrentBar = 1 then begin ....
and that does give the good results (so it's not really a problem but more an "exploration"), but I'd like to understand why Once does not work here. It can't be related to the GlobalVariables, since using CurrentBar = 1 does give the correct results.