how to get opened positions  StopLoss money?

Created at 04 Sep 2020, 07:22
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!
TR

trander002

Joined 14.02.2020

how to get opened positions  StopLoss money?
04 Sep 2020, 07:22


hi there

i want get and count all opened positions  [StopLoss money] , but i don't know how to do

 

 

i want get  this value  of all opened positions  (eg $216.66)

 

 

any one have ides?

 

thank you very much 


@trander002
Replies

PanagiotisCharalampous
04 Sep 2020, 08:42

Hi trander002,

Here is an example

            var totalSL = 0.0;
            foreach (var position in Positions)
            {
                var slAmount = (position.EntryPrice - position.StopLoss) * (Symbol.PipValue / Symbol.PipSize) * position.VolumeInUnits - (position.Commissions * 2);
                Print("Position ID: " + position.Id + " Stop Loss Amount: " + (-Math.Round((double)slAmount,2)));
                totalSL += (double)slAmount;
            }
            Print("Total SL " + (-Math.Round(totalSL, 2)));

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

trander002
04 Sep 2020, 11:46

RE:

PanagiotisCharalampous said:

Hi trander002,

Here is an example

            var totalSL = 0.0;
            foreach (var position in Positions)
            {
                var slAmount = (position.EntryPrice - position.StopLoss) * (Symbol.PipValue / Symbol.PipSize) * position.VolumeInUnits - (position.Commissions * 2);
                Print("Position ID: " + position.Id + " Stop Loss Amount: " + (-Math.Round((double)slAmount,2)));
                totalSL += (double)slAmount;
            }
            Print("Total SL " + (-Math.Round(totalSL, 2)));

Best Regards,

Panagiotis 

Join us on Telegram

 

 

thank you very much,  it  can work 

 


@trander002