Hi All,
I’m trying to code an automated trading system that will perform a trade if certain conditions are met. Assume there are 5 conditions, and the user can select any one, two, three, four or five of the conditions together. This means the user could select any number of conditions, and any possible permutation of conditions of that size. Hence, there are dozens of distinct possible choices.
In my code, each condition is being determined by a function, where the function will return a true or false value. Let’s call them FunctionCondition1, FunctionCondition2, FunctionCondition3….etc.
For example, if the user selects condition 1 and condition 3, the vba would be as follows:
If the user selects conditions 3,4 and 5, the vba would be:
I’m wondering if it’s possible to code something that will be able to automatically construct or use an If statement (depending on the selected conditions) without having to list all the possible combinations of conditions in If statements. Therefore, at the start of the code it would pick up (using simple Booleans) how many and which conditions have been selected by the user, and from that it would be able to construct (or work out) the appropriate If statement to use.
Any ideas?
I’m trying to code an automated trading system that will perform a trade if certain conditions are met. Assume there are 5 conditions, and the user can select any one, two, three, four or five of the conditions together. This means the user could select any number of conditions, and any possible permutation of conditions of that size. Hence, there are dozens of distinct possible choices.
In my code, each condition is being determined by a function, where the function will return a true or false value. Let’s call them FunctionCondition1, FunctionCondition2, FunctionCondition3….etc.
For example, if the user selects condition 1 and condition 3, the vba would be as follows:
Code:
If FunctionCondition1 = True And FunctionCondition3 = True Then etc
If the user selects conditions 3,4 and 5, the vba would be:
Code:
If FunctionCondition3 = True And FunctionCondition4 = True And FunctionCondition5 Then etc
I’m wondering if it’s possible to code something that will be able to automatically construct or use an If statement (depending on the selected conditions) without having to list all the possible combinations of conditions in If statements. Therefore, at the start of the code it would pick up (using simple Booleans) how many and which conditions have been selected by the user, and from that it would be able to construct (or work out) the appropriate If statement to use.
Any ideas?