How to output and/or test all possible permuations of 7 bools
Results 1 to 3 of 3

Thread: How to output and/or test all possible permuations of 7 bools

  1. #1
    I would like to test all probable combinations of 7 separate bool conditions. How do I do this? My initial inclination is to list all probable combinations like statements.

    7 t/f conditions = 2x2x2x2x2x2x2 = 128 combinations.

    For example:
    F F F F F F F = 1
    T T T T T T 1 = two
    T F F F F F F = 3
    T F F F F F F = 4
    T T F F F F F = 5
    etc.....
    etc.. .
    etc..

    1. I'd like to print a list in MT4 outputting ALL permutations so that I can see and compare.

    2. Ideally, I'd like to test all combinations with each mix as one integer 1 through 128 without having to create 128 separate if statements, however I'd still enjoy the list so I can manually compare the output and outcomes of each permutation.

    How do I do both and/or possibly above?

  2. #2
    If you signify each condition as a little in an integer then every combination is only an integer number 0 (all false) to 127 (all true). Example: If condition 3 is true, set 3rd bit to 1, otherwise set to 0, and so on.

  3. #3
    this is a script that builds a matrix with all possible combinations and prints it to the expert log
    https://www.forexforum.co.za/attachm...1494528864.mq4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.