Not tested, not compiled, just typed.
template<typename T> int ArrayFind(const T& array[], T value){ for(int iA=ArraySize(array) - 1; iA >= 0; --iA) if(array[iA] == value) return iA; return EMPTY; } string nonOpSym[]; int count=0; for(int iSym = ArraySize(trOpSym) - 1; iSym >= 0; --iSym) if(ArrayFind(opSym, trOpSym[iSym]) == EMPTY){ ArrayResize(nonOpSym, count+1); nonOpSym[count++] = trOpSym[iSym]; }Not tested, not compiled, just typed.
or
Not tested, not compiled, just typed.
#define INDEX uint template<typename Ti, typename To> INDEX remove_copy(const Ti& inp[], INDEX iBeg, INDEX iEnd, To& out[], INDEX oBeg, const Ti& value){ for(; iBeg != iEnd; ++iBeg){ if(!(inp[iBeg] == value) ) out[oBeg++] = inp[iBeg]; } return oBeg; } /////////////// string nonOpSym[]; int iEnd = ArrayCopy(nonOpSym, trSym); for(iOp=ArraySize(opSym) - 1; iOp >= 0; --iOp) iEnd = remove-copy(nonOpSym, 0, iEnd, nonOpSym, 0, opSym[iOp]); // Process nonOpSym[0 … iEnd-1]
Not tested, not compiled, just typed.
Not tested, not compiled, just typed.
Not tested, not compiled, just typed.or
Not tested, not compiled, just typed.
Not tested, not compiled, just typed.
Thanks,for the option 1, would it be possible not to create a function "int ArrayFind(const T& array[], T value)" but everything will be settled in just one loop ? Thanks
Thanks,for the option 1, would it be possible not to create a function "int ArrayFind(const T& array[], T value)" but everything will be settled in just one loop ? Thanks
string opSym[]={"AUDCHF","CADCHF","EURUSD","GBPJPY"}; string trSym[]={"AUDCAD","AUDCHF","AUDJPY","CADCHF","CADJPY","EURCAD","EURGBP","EURUSD","GBPAUD","GBPJPY","USDCAD","USDJPY"}; string nonOpSym[]; ArrayResize(nonOpSym,ArraySize(trSym)-ArraySize(opSym)); int n = 0; for(int h=0; h<ArraySize(trSym); h++) { int match = 0; for (int i=0;i<ArraySize(opSym);i++) { if (opSym[i]==trSym[h]) { match++; } } if (match<=0) { nonOpSym[n] = trSym[h]; n++; } } ArrayPrint(nonOpSym);
"AUDCAD" "AUDJPY" "CADJPY" "EURCAD" "EURGBP" "GBPAUD" "USDCAD" "USDJPY"
Dear Sardion, thanks. I think your way of coding should be the solution to run one loop and get the answer.
For the ...
int n = 0;
If I'm not wrong, I think the purpose is a bool flag.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi coders, good day to you. Let's say :-
I've 4 Symbols with Open Trades now :-
My EA has a total of 12 trading symbols readily for trading (set up in user input variable) :-
I created a new array :-
The purpose of the nonOpSym[] is to store the symbols without any open trades. Therefore, the expected output should be the balance of 8 symbols as follows :-
Now, how am I going to filter out the symbols of opSym[] from trSym[] in order to get the nonOpSym[] ?
I tried the following way but failed :-
Could you please help to correct my loop ? Thanks