Some mathematical help needed with permutations please - Aussie Stock Forums

1. ## Some mathematical help needed with permutations please

I am writing a scan in Bullcharts to alert me to possible weakness in a stock.

What the scan does is look for “any” combination of 4 out of a total of 6 “weak indicators”, without repeating a combination

I am aware of the formula n!/(r!*(n-r)!) using factorials !
where…
n = total number to choose from
r = number in combination

Using that formula: for any 4 out of 6, there are 15 possible non repeated combinations

Say the 6 indicators are:

A= MACD
B=OBV
C= DI+DI-
D=RSI divergence
E=Parabolic SAR
F=Chaikin Oscillator

Does anyone know a mathematical way or a website that will give me the actual 15 possible combinations without repeats. There must be an easier way than trial and error.

eg. Here are the first 5…..
....10 more to go

ABCD
ABCE
ABCF
ABDE
ABDF
…?

2. ## Re: Some mathematical help needed with permutations please

You could build a scan with all six indicators and rank them with equal importance (ie. 16.7% each). Then sort the results using their total ranking and review the results above 66% (4 x 16.7%).

3. ## Re: Some mathematical help needed with permutations please

That's a very good idea.... slightly different from my original scan concept. I haven't got into BC's importance ranking function yet. But I'll certainly give it a whirl.

I've been doing a bit of surfing and have come up with a few "number combination generator" sites.. mainly associated with generating powerball and lotto numbers. So far I haven't found a site that doesn't allow repeats. e.g
mytexttools.com/Permutation-Generator.html generates 1,296 4 digit combinations from 6 original choices. I'm fiddling about with Excel at the moment to cut out the repeats.

There must be a better site. Still searching.

Thanks again, Peter.

4. ## Re: Some mathematical help needed with permutations please

Have a Google for how to use a binary switch in programming.

For MS and BC: Give each indicator condition an integer number (x:2^(0-5)) then, for each bar add the scores:

x0:=MACD()>0;
x1:=RSI(14)>30;
x2:=RSI(14)>30;
...
x5:=Stoch(5,3,3)>80;

score := (32*x5) + ... + (4*x2) + (2*x1) + (1*x0);

This is the same as setting in binary: 111111 if all conditions were true, or 000000 if all the conditions were false.

=1, then in binary this would be 000001, or only the condition x0 was true.

=5, binary = 000101, or both conditions x0 and x2 are true.

=40, binary 101000, or conditions x5 and x3 were true.

=63, binary = 111111, or all the conditions were true

Doing the simple conversion from decimal to binary will tell you which bits (flags) were set or not set. (BTW: MS calculator does binary<-->decimal conversions )

wabbit

P.S. "There are 10 types of people; those who can count in binary and those who cannot!"

5. ## Re: Some mathematical help needed with permutations please

Originally Posted by wabbit
Have a Google for how to use a binary switch in programming.

For MS and BC: Give each indicator condition an integer number (x:2^(0-5)) then, for each bar add the scores:

x0:=MACD()>0;
x1:=RSI(14)>30;
x2:=RSI(14)>30;
...
x5:=Stoch(5,3,3)>80;

score := (32*x5) + ... + (4*x2) + (2*x1) + (1*x0);

This is the same as setting in binary: 111111 if all conditions were true, or 000000 if all the conditions were false.

=1, then in binary this would be 000001, or only the condition x0 was true.

=5, binary = 000101, or both conditions x0 and x2 are true.

=40, binary 101000, or conditions x5 and x3 were true.

=63, binary = 111111, or all the conditions were true

Doing the simple conversion from decimal to binary will tell you which bits (flags) were set or not set. (BTW: MS calculator does binary<-->decimal conversions )

wabbit

P.S. "There are 10 types of people; those who can count in binary and those who cannot!"

Brilliant!

6. ## Re: Some mathematical help needed with permutations please

Thank you, Wabbit.

There are obviously neater ways to skin a cat that my cumbersome scan.

Rethinking your idea too, Peter. It obviously does what I want to do in a far quicker way.

Thank you both kindly for your excellent suggestions.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Aussie Stock Forums