How get volume of all open Buy and Sell ?

Created at 21 Mar 2019, 14:09
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
LU

lukas.ourada

Joined 11.03.2019

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.


@lukas.ourada
Replies

lgwsyqnfr
23 Mar 2019, 06:49

What currency? all pairs ?


@lgwsyqnfr

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