Nguyen Van Luong: Why do these two functions different results? I've always used method 1, but I found the results unsatisfactory, so I tried method 2 and it gave me the desired results.
- Does Save_History_StrongConsensus(A,B,C) return a bool? If yes the results are the same.
- Method 1, just or's the values. Invalid with integers greater than 1.
- Method 2, check for zero or non-zero, works with integers.
William Roeder #:
Does Save_History_StrongConsensus(A,B,C) return a bool? If yes the results are the same. Method 1, just or's the values. Invalid with integers greater than 1. Method 2, check for zero or non-zero, works with integers.
Of course, the Save_History_StrongConsensus(A,B,C) function returns a bool. It's the function below:
bool Save_History_StrongConsensus(const char s, const char AA, const char idx) { bool Ret = false; if (AA != 0 && Data[s].StrongConsensus_Begin[idx] == T1970) Ret = Update_History_StrongConsensus(s, idx, true); else if (AA == 0 && Data[s].StrongConsensus_Begin[idx] != T1970) Ret = Update_History_StrongConsensus(s, idx, false); return Ret; }
bool Update_History_StrongConsensus(const char s, const char idx, const bool bAddNew) { //Create or open the database in the common terminal folder string filename = Filename(EXPERT_NAME); int db = DbOpen(filename, __FUNCTION__); if (db == INVALID_HANDLE) { Print("DB: ", filename, " open failed with code ", GetLastError()); return false; } else { //TODO... } //Close the database DatabaseClose(db); return bAddNew; }
Your method 1 has "shortcut effect" (brief:estimate) of logical expression.
Please refer to https://www.mql5.com/en/docs/basis/operations/bool
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Why do these two functions different results? I've always used method 1, but I found the results unsatisfactory, so I tried method 2 and it gave me the desired results.
Method 1:
Method 2: