How to get current value of a "trailing stop loss"?

Created at 26 Mar 2019, 12:47
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!
FI

firemyst

Joined 26.03.2019

How to get current value of a "trailing stop loss"?
26 Mar 2019, 12:47


HI everyone:

Is it possible to obtain the current value of the trailing stop loss in Pips or otherwise after several ticks when it moves?

If so, how?

Thank you :-)


@firemyst
Replies

PanagiotisCharalampous
26 Mar 2019, 14:07

Hi FireMyst,

Thanks for posting in our forum. Here is an example for buy positions

 var pips = (Positions[0].StopLoss - Positions[0].EntryPrice) / Symbol.PipSize;

Best Regards,

Panagiotis


@PanagiotisCharalampous

firemyst
26 Mar 2019, 16:02

Thank you for your reply, but that's not what I meant. :-)

In the "OnTick" method, after I place an order:

ExecuteMarketOrder(TradeType.Buy, Symbol, PositionSize, MyLabel, StopLossInPips, null, null, null, true);

I had an area of code that gets run through if I have at least 1 open position:

if (Positions.Count > 0)
                    {
                        Position position = Positions[0];
                        Print("Stoploss: {0},", position.StopLoss);
                    }

 

The value of position.StopLoss never seemed to change, even though I can see the trailing stop loss move on the chart in backtest mode.

 

However, I've since managed ot figure out my issue - I wasn't looking at the correct times in the log. Doh! :-) 

Anyway, I appreciate your response :-)

 


@firemyst