What kind of data should I be putting in the trade.buy.volume property? Is this the number of shares I wish to buy? In some of the MT5 code I see values like 0.10 but I don't know what that means.
Thank you...
Opens a long position with specified parameters.
bool Buy( double volume, // position volume const string symbol=NULL, // symbol double price=0.0, // execution price double sl=0.0, // stop loss price double tp=0.0, // take profit price const string comment="" // comment )
Parameters
volume
[in] Requested position volume.
So 'volume' is the volume you want to buy. Stocks (very often) have a multiple of '1', but for forex trading, the volume (very often) is a multiple of '0.01'.
- www.mql5.com
Opens a long position with specified parameters.
Parameters
volume
[in] Requested position volume.
So 'volume' is the volume you want to buy. Stocks (very often) have a multiple of '1', but for forex trading, the volume (very often) is a multiple of '0.01'.
So if I wanted to buy 20 (stock) shares, then I would specify a double data type such as: 20.0 correct?
So if I wanted to buy 20 (stock) shares, then I would specify a double data type such as: 20.0 correct?
Yes, the volume is specified with type ' double '
double volume, // position volume
After I posted my question I read that stock volume is given in Lots, where 1 'round' lot is 100 shares of stock. 'Odd' lots are less than 100 shares.
So if I set my buy volume to 1.0 then I would be asking to buy 100 shares of a given stock.
After I posted my question I read that stock volume is given in Lots, where 1 'round' lot is 100 shares of stock. 'Odd' lots are less than 100 shares.
So if I set my buy volume to 1.0 then I would be asking to buy 100 shares of a given stock.
Mathematics, third grade:
1 != 100
:)
Yet:
SYMBOL_VOLUME_MIN not always equal SYMBOL_TRADE_CONTRACT_SIZE
Use script:
//+------------------------------------------------------------------+ //| All Symbols all path.mq5 | //+------------------------------------------------------------------+ #property version "1.001" //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- string array[][4]; // [][0] - Symbol, [][1] - Path, [][1] - Volume min int total=SymbolsTotal(false); ArrayResize(array,total); for(int i=0; i<total; i++) { string name=SymbolName(i,false); array[i][0]=name; array[i][1]=SymbolInfoString(name,SYMBOL_PATH); array[i][2]=DoubleToString(SymbolInfoDouble(name,SYMBOL_VOLUME_MIN),2); array[i][3]=DoubleToString(SymbolInfoDouble(name,SYMBOL_TRADE_CONTRACT_SIZE),2); } string array_description[4]= {"Symbol","Path","Volume min","Contract size"}; ArrayPrint(array_description); ArrayPrint(array); } //+------------------------------------------------------------------+
result:
[ 43,] "LKOH.MM" "Stock Markets\Russia\MICEX20\LKOH.MM" "1.00" "1.00" [ 44,] "MAGN.MM" "Stock Markets\Russia\MICEX Other\MAGN.MM" "1.00" "100.00" [ 45,] "MGNT.MM" "Stock Markets\Russia\MICEX20\MGNT.MM" "1.00" "1.00" [ 46,] "MOEX.MM" "Stock Markets\Russia\MICEX20\MOEX.MM" "1.00" "10.00" [ 47,] "USDHKD" "Forex\Forex\USDHKD" "0.01" "100000.00" [ 48,] "USDILS" "Forex\Forex\USDILS" "0.01" "100000.00" [ 49,] "USDMXN" "Forex\Forex\USDMXN" "0.01" "100000.00" [ 50,] "MTSS.MM" "Stock Markets\Russia\MICEX20\MTSS.MM" "1.00" "10.00" [ 51,] "NLMK.MM" "Stock Markets\Russia\MICEX20\NLMK.MM" "1.00" "10.00" [ 52,] "NOKSEK" "Forex\Forex\NOKSEK" "0.01" "100000.00"
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
What kind of data should I be putting in the trade.buy.volume property? Is this the number of shares I wish to buy? In some of the MT5 code I see values like 0.10 but I don't know what that means.
Thank you...