# error 202, 20

I have this little logic that is supposed to help me building up cases for names of tree leaves.

The names can consist of n terms, say MA1, MA2, MA3, MA4... MAn. They can all be used only once because each of them describe a unique combination of the said indicators from highest to lowest.

So it will be like drawing balls from a basket until there is none left, which means that the whole amount of combinations will be "n!" (pronounciation factorial; 1*2*3*4*...*n) .

It is a part of an EA aiming towards decision tree commitees. I just haven't found a solid practical grip on the tree thing yet so I am beating about the bush here.

```//global variables:
string nameTag[];
string wholeOfCases[];
int factorialArray[], count;
int      numPrice=4;

int OnInit()
{
ArrayResize(nameTag,numPrice);
ArrayResize(factorialArray,numPrice);

nameTag[0]="MA1";
nameTag[1]="MA2";
nameTag[2]="MA3";
nameTag[3]="MA4";

PermutateCaseNames(numPrice);

//---
return(INIT_SUCCEEDED);
}

void OnTick()
{
count++;                        // to be sure if it continues after OnInit, here some stop point material.
}
//+------------------------------------------------------------------+
//|                                                                            |
//+------------------------------------------------------------------+
int   GetFactorial(int num)
{
int   res = 1;
for(int i=1; i<=num; i++)
{
res*=i;
Print("res= ",res);
}
return(res);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

void  PermutateCaseNames(int num)
{
for(                           // basically for loop headers, just so I can see which
int i=0 ;                      // part of it is involved in the array of range error
i<num ;
i++)                           // Get factorials of 1 through n
{
factorialArray[i]=GetFactorial((i+1));
Print("factorialArray[",i,"] = ",factorialArray[i]);
}

for(                               // if the yellow part is commented out, it runs and continues in OnTick
int z=0 ;
z<factorialArray[3] ;              //debugger stops with errors 76,20 now: "Function must return a value". ButDebugger shows that factorialArray[3]=24
z++)                               //factorialArray[n-1] contains n!
{

wholeOfCases[z]="";

for(int a=0 ; a<factorialArray[2] ; a++)
{
wholeOfCases[a]+=nameTag[0];

for(int b=0 ; b<factorialArray[1] ; b++)
{
wholeOfCases[a]+=nameTag[1];

for(int c=0 ; c<factorialArray[1] ; c++)
{
wholeOfCases[a]+=nameTag[2];

for(int d=0 ; d<factorialArray[1] ; c++)
{
wholeOfCases[a]+=nameTag[3];
}
}
}

} }

for(int z=0 ; z<factorialArray[3] ; z++)
{
Print("case ",wholeOfCases[z]);
}

}```

Now the compiler gave me array out of range error 202,20

and then 204,20.

20 is not in the list of error codes in documentary. Is there a way to find

202 says "A constant variable cannot be passed by a non-constant reference". I used a global "numPrice" variable first and not a reference "num1", so why am I getting this?

204 says "Failed to access protected class member." I don't use classes here, so why am I getting this? So I exchanged the structure string array that I had used instead of the nameTag[].

76,20 says "Function must return a value". What function?

I have been changing little things like how I pass the variables

78,20 says "Not all control paths return a value." What control paths?

77,20: "void function returns a value"

Now I am seperating the factorial part and the permutation part and run them both as voids and it says 81,20: "Two OnCalCulate() are defined. OHLC version will be used" Huh. I am not even using an Indicator here...? Again critical error at the for loop of permutation factorials.

Anybody have a hint?

The checks a trading robot must pass before publication in the Market
• www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.

The error numbers youvare getting are, (>line<, >column<) and show you the location in your code where your program has failed.

Btw, factorial 15 will already render uncomputable.

I suppose, depending on the complexity, your limit for OnTick being still somewhat reactive will be around 5 to 7 max. Maybe up to 10, but surely nothing beyond that.

10! = 3 628 800
15! = 1 307 674 368 000

These are the iterations the CPU has to compute. That's a lot of work.

Good luck with that.

Dominik Egert #:
The error numbers youvare getting are, (>line<, >column<) and show you the location in your code where your program has failed.

Btw, factorial 15 will already render uncomputable.

I suppose, depending on the complexity, your limit for OnTick being still somewhat reactive will be around 5 to 7 max. Maybe up to 10, but surely nothing beyond that.

10! = 3 628 800
15! = 1 307 674 368 000

These are the iterations the CPU has to compute. That's a lot of work.

Good luck with that.

Haha.

As for the higher factorials alright I have already calculated that I am going to use around 13
But it won't run often, only at OnInit if needed. Might need around 100GB storage for the leaf names alone

Once everything is up and running I will look into getting a better O(n).

Now for the original problem: factorial[3]=4!
so there is only 24 leaf names in this prototype.
I am getting the critical error mostly after leaving the factorial calculation loop. I don't see the problem since Debug shows that the values of
factorial[i], i={1,2,3,4} are calculated correctly. And if i comment out the program part that is supposed to compose the leaf names, I get to OnTick and Tick count goes up. So it seems the error can only be within the last loop construction.

But this happens also if I set those two up as independent voids.
But I'd think that if the error is inside the last program part, so there is a piece of information missing because how does Debug perceive the error before it happens? It doesn't.
Something in my code goes against the inner workings of MT5.

There are no line numbers on your post, so it's hard to read...

But I suppose it's some coding error.
Reason: