Robert Browne:
If I did this Would this work? Which leads to the next question, is the "switch" call better than an "if, else if" call such as this Which leads to a query on functions. Is one better "embedding" these function calls into the program or would it be better to define the function inside the block such as this? Final question is in relationship to static variables vs global variable. It's fairly simple. If one declares a global variable but that variable is only used inside one block, is one better off declaring it as a static variable? Now to give a bit of content to why I ask these questions. |
|
Don't use constants when you mean an enumeration | #define NoBox 0 #define BoxForming 1 #define ActiveBox 2 #define ActiveTradePattern 3 int GetBoxCondition; int somefunc() { if (A==B) GetBoxCondition = NoBox; |
Use verbs in function names, nouns in variable names. GetBoxCondition sounds like a operation but you can't get anything using that. | enum BoxCondition { NoBox, BoxForming, ActiveBox, ActiveTradePattern }; BoxCondition boxCondition; int somefunc() { if (A==B) boxCondition = NoBox; |
|
Don't use constants when you mean an enumeration | |
Many thanks for such a prompt responce. Looks like time to research enumerations. Busy weekend ahead. Thanks again.
Many thanks for such a prompt responce. Looks like time to research enumerations. Busy weekend ahead. Thanks again.
In relation to this expression
enum BoxCondition { NoBox, BoxForming, ActiveBox, ActiveTradePattern }; BoxCondition boxCondition; int somefunc() { if (A==B) boxCondition = NoBox;
Been doing my homework and have find some examples where the author would of made the same expression but like this
enum BoxCondition { NoBox, BoxForming, ActiveBox, ActiveTradePattern } boxCondition ; int somefunc() { if (A==B) boxCondition = NoBox;
or
enum BoxCondition { NoBox, BoxForming, ActiveBox, ActiveTradePattern }; enum BoxCondition boxCondition; int somefunc() { if (A==B) boxCondition = NoBox;
would there be a reason for them doing so? Are they right/wrong for doing so?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Quick couple of questions, hoping someone can help.
If I did this
Would this work?
Which leads to the next question, is the "switch" call better than an "if, else if" call such as this
Which leads to a query on functions. Is one better "embedding" these function calls into the program or would it be better to define the function inside the block such as this?
Final question is in relationship to static variables vs global variable. It's fairly simple. If one declares a global variable but that variable is only used inside one block, is one better off declaring it as a static variable?
Now to give a bit of content to why I ask these questions. I'm a very amateur programmer with sufficient skills to develop "simple"bots for back testing. However recently, the bots I build lately seem to slow strategy tester down with each pass made. This is very frustrating. After some research the answer is probably reflective of my programming skills and understanding of program structure . Therefor I want to re-engineer my bots but do things for the right reasons, not for the wrong. So I hope your answers take this into account.
Many thanks in advance