Function to read Commission

Back to topics list To post a new topic, please log in or register
avatar
228
jollydragon 2015.08.11 11:41
 

Who knows whether there is a function or code that can read out the commission of a forex symbol before opening orders?  

avatar
228
jollydragon 2015.08.13 04:32 #
 

 

Besides, is there a way to read out all the symbol names of a broker automatically?  

avatar
Moderator
3418
GumRai 2015.08.13 06:55 #
 
   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 above
This will put them in an array
avatar
228
jollydragon 2015.08.14 03:09 #
 
GumRai:
This will put them in an array
Thank you very much !
avatar
2017
gooly 2015.08.16 11:17 #
 
GumRai:
...
//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.

avatar
Moderator
3418
GumRai 2015.08.16 12:08 #
 
gooly:

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 

avatar
2017
gooly 2015.08.16 14:14 #
 
GumRai:

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!



avatar
13001
WHRoeder 2015.08.16 20:00 #
 
No matter what is the property of the target array - as_series=true or as_series=false. Data will be copied so that the oldest element will be located at the start of the physical memory allocated for the array. -- CopyRates - MQL4 Documentation

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.



Back to topics list  

To add comments, please log in or register