How get volume of all open Buy and Sell ?
            
                 21 Mar 2019, 14:09
            
                    
Hello
Please, how I can get sum total volume of open Buy position and open Sell position? I need get ratio between volume sell/buy.
I have open many positions with different size.
Replies
                     lukas.ourada
                     23 Mar 2019, 09:22
                                    
hi
i use only AUDCAD or XAUUSD. Best solution for my is get total volume by symbol (not all pair together).
@lukas.ourada
                     lgwsyqnfr
                     23 Mar 2019, 12:05
                                    
I am newer cBot from mql. Ithink you can do so:
foreach (var position in Positions)
            {
                if (position.SymbolCode == Symbol.Code)
                {
                    double lot = position.VolumeInUnits;
                    if (position.TradeType == TradeType.Buy)
                    {
                        buylots += lot;
                    }
                    if (position.TradeType == TradeType.Sell)
                    {
                        selllots += lot;
                    }
                }
            }
@lgwsyqnfr
                     lgwsyqnfr
                     23 Mar 2019, 12:08
                                    
           double buylots =0, selllots =0;
           foreach (var position in Positions)
            {
                if (position.SymbolCode == Symbol.Code)
                {
                    double lot = position.VolumeInUnits;
                    if (position.TradeType == TradeType.Buy)
                    {
                        buylots += lot;
                    }
                    if (position.TradeType == TradeType.Sell)
                    {
                        selllots += lot;
                    }
                }
            }
@lgwsyqnfr
                     lukas.ourada
                     25 Mar 2019, 18:06
                                    
RE:
lgwsyqnfr said:
double buylots =0, selllots =0; foreach (var position in Positions) { if (position.SymbolCode == Symbol.Code) { double lot = position.VolumeInUnits; if (position.TradeType == TradeType.Buy) { buylots += lot; } if (position.TradeType == TradeType.Sell) { selllots += lot; } } }
Thank you very much, work perfect!
@lukas.ourada

lgwsyqnfr
23 Mar 2019, 06:49
What currency? all pairs ?
@lgwsyqnfr