Optimisation of algorithms. - page 10

 
Igor Makanu:

your example is not a combination but a permutation without repetition

And my example is a conjunction without repetition.

Oh, so that's what it's supposed to be?

0

1

01

11

001

101

011

...


Then the code won't be much more complicated for you, but you definitely don't need that many loops.

 
Andrey Dik:

Oh, so that was the plan?

Yes

I had to generate file names in the tester, each file is a strategy parameter

and by generating combinations without repetitions all combinations of TS are combined, on the last page of the topic is the code that does this


and your problem is easy to google "permutations without repetitions recursion s++"

 
Igor Makanu:

and your problem is easily googled "permutations without recursion recursion C++".

I googled it, but mostly not universal solutions come up.

But it's much more interesting and informative to do and figure it out yourself).

 
Andrey Dik:

can I have the code?

input int      StartN = 5;
input int      EndN   = 7;
input int      CountN = 4;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
  {
   for(int i1=0; i1<30; i1++)
     {
      Print(CombinationGenerator(i1,StartN,EndN,CountN));
     }
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string CombinationGenerator(uint iteration_index,int startN, int endN, int countN)
  {
   string result;
   int base=endN-startN+1;
   uint ml=base;
   for(int i1=0; i1<countN; i1++)
     {
      uint md=iteration_index%base;
      result=result+string(md+startN);
      iteration_index=(iteration_index-md)/base;
     }
   return result;
  }

It's simple:

2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5555
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6555
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7555
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5655
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6655
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7655
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5755
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6755
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7755
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5565
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6565
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7565
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5665
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6665
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7665
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5765
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6765
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7765
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5575
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6575
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7575
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5675
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6675
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7675
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5775
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6775
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7775
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       5556
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       6556
2020.07.13 16:45:27.456 test3 (EURUSD,M1)       7556
 
Aliaksandr Hryshyn:

It's simple:

Cool, thanks! I'll have a look.