You need to use brackets: { ... }
string oSym=""; for(int i=0; i<symbols.Total(); i++) { oSym=symbols[i]; Print(oSym+" High "+DoubleToStr(iHigh(oSym,1440,1),5)); }
Thanks Yashar. My intention is to make the "oSym" outside the bracket, so that the "oSym" can even be used to run loops for the 5 symbols (presuming there are 5 symbols that with open orders) such as below :-
int obStoF5Sf=0; for(int i=0; i<=100; i++) { double cSto0=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i), cSto1=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+1), cSto2=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+2), cSto3=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+3), cSto4=iStochastic(oSym,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));
Would you be able to help 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
I do not understand what you mean but I guess you are looking for such a thing...
int obStoF5Sf=0; for(int j=0; j<symbols.Total(); j++) { string oSym=symbols[j]; for(int i=0; i<=100; i++) { double cSto0=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i), cSto1=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+1), cSto2=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+2), cSto3=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+3), cSto4=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+4); if(cSto0<cSto1 && cSto1>=cSto2 && cSto2>cSto3 && cSto3>cSto4 && cSto1>80) { obStoF5Sf=i; break; } } }
I do not understand what you mean but I guess you are looking for such a thing...
Hi Yashar, thanks for your kindness to help.
As we know, the symbols with open orders are all stored in the buffer symbols[i]. Let's say there are 5 symbols that with open orders : AUDJPY, EURJPY, GBPUSD, USDCHF, XAUUSD
The outputs of below Prints are printing the 5 symbols' values respectively.
Print(oSym+" High "+DoubleToStr(iHigh(oSym,1440,1),5)); Print(oSym+" OB Sto Sf : "+IntegerToString(obStoF5Sf));My mission : prior to the 2 Prints above, I intend to "convert" the symbols[i] inro a string variable "oSym" first and this "oSym" will keep on "rotating" the 5 symbols above (to index the symbols) :-
string oSym=""; for(int i=0; i<opSym.Total(); i++) { ... } // I don't know what would be the coding steps to do it ...
If the above variable "oSym" is resolved, only then I will start carrying out the 2 Prints.
I hope you can understand my mission ...
int obStoF5Sf=-1; int symIndex=-1; for(int j=0; j<symbols.Total(); j++) { string oSym=symbols[j]; for(int i=0; i<=100; i++) { double cSto0=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i), cSto1=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+1), cSto2=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+2), cSto3=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+3), cSto4=iStochastic(oSym,60,5,3,3,0,0,MODE_MAIN,i+4); if(cSto0<cSto1 && cSto1>=cSto2 && cSto2>cSto3 && cSto3>cSto4 && cSto1>80) { obStoF5Sf=i; symIndex=j; break; } } } ... ...Print(symbols[symIndex]+" High "+DoubleToStr(iHigh(symbols[symIndex],1440,1),5)); Print(symbols[symIndex]+" OB Sto Sf : "+IntegerToString(obStoF5Sf));
Print(symbols[symIndex]+" High "+DoubleToStr(iHigh(symbols[symIndex],1440,1),5)); Print(symbols[symIndex]+" OB Sto Sf : "+IntegerToString(obStoF5Sf));
Would it be possible to use "oSym" instead of "symbols[symIndex]" such as below ? The "oSym" will keep on "rotating" the 5 symbols.
Print(oSym+" High "+DoubleToStr(iHigh(oSym,1440,1),5)); Print(oSym+" OB Sto Sf : "+IntegerToString(obStoF5Sf));
Hi Yashar, just FYI, I'm only busy with the Entry and Exit functions to set conditions for signals to OrderSend() and OrderClose().
I tried to create a function such as ...
void OpOrd(string symbols) { ... }
to migrate all the open orders calculations so that the outputs can be called into the Entry and Exit functions for my signals conditions calculations. Inside the Entry and Exit functions, I intend to use the "oSym" for loops and other calcultions ... however, I failed.
Would it be possible to code in such direction ? Thanks
- 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, I'm learning coding now.
Pertaining to this post that quoted by "nicholish en" : https://www.mql5.com/en/forum/305424#comment_10829666From 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 and to avoid using the [i] so that if I want to get the iHigh price for all the open trades symbols, such as :-
How to "convert" the symbols[i] to symbols ? Thanks
FYI, I tried to firstly to "convert" as follows :-
but the output only has 1 symbol (the first symbol), the other 4 symbols are not shown, why ?