Hi coders, I’m learning coding now. I got a set of codes from MQL5 (to get the symbols that with open orders)
#include <arrays/arraystring.mqh>
void OnStart()
{
CArrayString symbols;
for (int i=0; OrderSelect(i, SELECT_BY_POS); i++)
if (symbols.SearchLinear(OrderSymbol()) < 0)
symbols.Add(OrderSymbol());
for (int i=0; i<symbols.Total(); i++)
Print(symbols[i]);
}
for (int i=0; i<symbols.Total(); i++)
Print(symbols[i]);
From my understanding, the “symbols” is a buffer to store all the open trades symbols. Let’s say there are 5 symbols that with open orders, is there a way to index the open trades symbols, sort the 5 symbols and to avoid using the [i] so that if I want to get the iHigh price for all the open trades symbols, such as :-
Print(DoubleToStr(iHigh(symbols,1440,1),5));
// expected output would be the High price of the 5 symbols
I also intend to run a loop to get the shift for the 5 symbols too :-
int obStoF5Sf=0; for(int i=0; i<=100; i++) {
double cSto0=iStochastic(symbols,60,5,3,3,0,0,MODE_MAIN,i), cSto1=iStochastic(symbols,60,5,3,3,0,0,MODE_MAIN,i+1),
cSto2=iStochastic(symbols,60,5,3,3,0,0,MODE_MAIN,i+2), cSto3=iStochastic(symbols,60,5,3,3,0,0,MODE_MAIN,i+3),
cSto4=iStochastic(symbols,60,5,3,3,0,0,MODE_MAIN,i+4);
if(cSto0<cSto1 && cSto1>=cSto2 && cSto2>cSto3 && cSto3>cSto4 && cSto1>80) {
obStoF5Sf=i;
break;
}
} // to get Overbought Shift
Print(oSym+" OB Sto Sf : "+IntegerToString(obStoF5Sf));
How to “convert” the symbols[i] into oSym and sort the 5 oSym according to MODE_ASCEND ? What are the coding steps to do so ? Thanks
FYI, I tried to firstly to “convert” as follows :-
string oSym="";
for(int i=0; i<symbols.Total(); i++) oSym=symbols[i];
Print(oSym+" High "+DoubleToStr(iHigh(oSym,1440,1),5));
but the output only has 1 symbol (the first symbol), the other 4 symbols are not shown, why ?