Besides, is there a way to read out all the symbol names of a broker automatically?
int number = SymbolsTotal(true); //If true all symbols, if false just those in the Market Watch window string SymbolArray[]; ArrayResize(SymbolArray,number); for(int index=0;index<number;index++) SymbolArray[index]= SymbolName(index,true); // must be true or false, the same as aboveThis will put them in an array
This will put them in an array
...
//If true all symbols, if false just those in the Market Watch window
I read in the reference:
SymbolsTotal Returns the number of available (selected in Market Watch or all) symbols. int SymbolsTotal( bool selected // True - only symbols in MarketWatch ); Parameters selected [in] Request mode. Can be true or false. Return Value If the 'selected' parameter is true, the function returns the number of symbols selected in MarketWatch. If the value is false, it returns the total number of all symbols.
Which is the exactly the opposite.
I read in the reference:
Which is the exactly the opposite.
Well done for spotting the deliberate mistake :)
No, seriously, I wrote that little snippet of code a long time ago and I must have made an error in my commenting
Well done for spotting the deliberate mistake :)
No, seriously, I wrote that little snippet of code a long time ago and I must have made an error in my commenting
May be it is not your fault - but a mistake in their reference.
Look at MqlRates and CopyRates():
Gets history data of MqlRates structure of a specified symbol-period in specified quantity into the rates_array array. The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar.
"0 means current bar" which should have the highest time stamp but is is exactly the opposite:
//+------------------------------------------------------------------+ //| Test_MqlRates.mq4 | //| Copyright 2014, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- MqlRates Rates2[2]; int i = Bars -3; while(i-->0) { int anz = CopyRates(_Symbol,_Period,i,2,Rates2); Comment("Mt4-Ref: The elements ordering of the copied data is from present to the past, "+ "i.e., starting position of 0 means the current bar.\n", (string)i,"] 1=prevBar: ",Rates2[1].time," 0=currentBar: ",Rates2[0].time ); DebugBreak(); } } //+------------------------------------------------------------------+
Try that in the debugger!
Results exactly as documented.
Unless you want to modify the array use ArrayCopyRates - MQL4 Documentation only need one call in OnInit, auto-updates, contains all bars, no copying actually performed, in series order.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Who knows whether there is a function or code that can read out the commission of a forex symbol before opening orders?