Bit of a strange test as the high will almost certainly be larger than the low.
int barsToCheck=10; bool result=true; for(int x=1;x<=barsToCheck;x++) { if(High[x]<=Low[x]) result=false; break; }
Using a function
int barsToCheck=10; bool result=true; for(int x=1;x<=barsToCheck;x++) { result=Check(x); if(result==false) break; } //+------------------------------------------------------------------+ bool Check(int x) { return(High[x]>Low[x]); } //+------------------------------------------------------------------+
This might help... This is a pattern I use for p-hacking expressions with the optimizer.
void OnStart() { int x = 10; bool res = compare_arrays(High, GT, Low, 1, x); } //+------------------------------------------------------------------+ enum COMPARISON_OPS{LT, LTE, EQ, GTE, GT, ALWAYS_TRUE, ALWAYS_FALSE}; template <typename T> bool compare(const T item1, const COMPARISON_OPS op, const T item2) { switch(op){ case ALWAYS_TRUE: return true; case LT: return item1 < item2; case LTE: return item1 <= item2; case EQ: return item1 == item2; case GTE: return item1 >= item2; case GT: return item1 > item2; default: return false; } } template <typename T> bool compare_arrays(const T &array1[], const COMPARISON_OPS op, const T &array2[], const int start=0, const int count=WHOLE_ARRAY) { int len = fmin(ArraySize(array1), ArraySize(array2)); if(count != WHOLE_ARRAY) len = fmin(len, start + count); int i = len - 1; for(; i>=start; --i) if(!compare(array1[i], op, array2[i])) break; return i < start; }
@Keith Watford Thank you , It's very clarify code
@nicholi shen Thank for pattern, I have been trying to read this code,but still not understand it.
Could you tell me about P-hacking expression ? or leave introduction of it by link .
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
Hi experts,
I 'd like to remake the following code shortly.
plz consider this
If( High[1]>Low[1] and High[2]>Low[2] and High[3]>Low[3] and ..... High[x]>Low[x] )
A=True;
1.How to convert it to while loop or function based on x.
2. Can we replace High>Low to function, If the algorithm has more complex than High > Low.
thank you very much