Combinatorics
Info
The Combinatorics is a Library for MetaTrader 5 that initial library of combinatorics functions. Combinatoricsis a branch of , that studies discrete structures, (, , arrangement and ) and relations on them (for instance, ).
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Library works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Libraries folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Combinatorics
1. Storage: Place library files in the MQL/Libraries directory to ensure they are accessible to your projects.
2. Implementation: Include the library in your code using the #import directive, ensuring you match the exact function names and parameters.
3. Compilation: Ensure the library is present in the directory before you compile your main EA or script, as the compiler links them during this phase.
4. Management: Keep libraries organized in sub-folders if you manage many custom functions to maintain a clean project structure.
Frequently Asked Questions
Q: What is a library file used for? A: Libraries store reusable code modules, allowing you to centralize common logic used by multiple EAs or indicators.
Q: Is a library executable? A: No, libraries are non-executable files containing functions; they must be imported into an EA, indicator, or script to function.
Q: Can I update a library while the platform is running? A: You should compile your EA or script after updating a library to ensure the latest code changes are integrated.
What this tool does
Initial library of combinatorics functions.
Typical Use Case
This Library excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Library works on MetaTrader 5. Place the file in the MQL5/Libraries folder and restart the terminal.
Description & Settings
Related: state - behavioral design pattern - another powerful library for MetaTrader 5 traders.
Initial library of combinatorics functions.
Combinatorics
is a branch of , that studies discrete structures, (, , arrangement and ) and relations on them (for instance, ). Combinatorics is related to many other areas of such as , , and has a wide spectrum of application in different areas of knowledge (for instance in , , ).
Also recommended: Signal MA Above Below 2 - similar library with strong performance on MetaTrader 5.
1) The first function:Factorials are often used in , and .
Factorial is an extremely fast growing function. It grows faster than of any degree and faster than (but slower than double exponential function).
That is why returned value must be of type. It is done because factorial grows too fast and already the 13! does not fit in the ranges of a type.
2) The second function:
Combinations allow to select unique set of elements from some set consisting of N elements. Each set will have k elements.
Suppose that there are 10 trading signals. And for the trading system only 3 are to use. Then, for the further analyses all possible sets (3 signals) from the set of 10 signals should be selected.
Hence the number of such sets will be the number of combinations:
C(k,N) = C(3,10) = 120.
I.e. there are 120 unique combinations on 3 signals on each.
3) The third function:
Combinations with repetitions admit that in the set some element can be presented more than one time. Suppose that there are five fruits. The set consisting of 3 elements has 2 oranges and 1 apple. Such set is a combination with repetitions. Orange repeated.
As for the set of 10 signals and possible sets (3 signals), we find a number of combinations with repetitions:
~C(k,N) = ~C(3,10) = 220.
4) The fourth function:
Arrangements differ from the combinations in a fact that not the kit is important but the order of elements in the set. Suppose that there are 2 sets with 3 elements: apple-orange-banana, apple-banana-orange. In terms of the combinations we have only one combination (one set of participants). But concerning arrangement there are 2 combinations (participants changed order in a set).
It is clear that there will be more arrangements than combinations. For instance, from the set of signals (10 signals) and possible sets (3 signals) we can get as many arrangements:
A(k,N) = A(3,10) = 720.
5) The fifth function:
I.e. as in case with combinations admit that elements in a set can be repeated.
Then for the set of 10 signals and possible sets (3 signals) we will get such a number of arrangements with repetitions:
~A(k,N) = ~A(3,10) = 1000.
6) The sixth function:
Permutation allows to know how many approaches can be to change the order in the set of elements.
So for the set of signals (10 signals) we can get as many permutations:
P(N) = P(10) = 3 628 800.
And for the set of 3 signals we can get as many permutations:
P(3) = 6.
Number of permutations returns factorial. Thus such a difference between the number of permutation for 3 and 10 elements.
7) The seventh function:
I.e. as in case with combinations admit that elements in a set can be repeated.
Only as a parameter passes an array in which each element indicates how many times it can be repeated.
For instance, there are 3 signals, each is repeated one time, then:
Suppose that the first signal can be repeated 2 times, then:
You may also like: Balance Reset - excellent alternative for library users on MetaTrader 5.
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.