Robot.ModifyPosition(Position, double?, double?)' is obsolete

Created at 05 Feb 2025, 16:05
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!
CI

ciprescool7

Joined 05.02.2025

Robot.ModifyPosition(Position, double?, double?)' is obsolete
05 Feb 2025, 16:05


Hi people:

I have a problem whit this linea on my code:

        protected override void OnTick()
        {
            foreach (var position in BotPositions)
            {
                double newStopLoss = position.TradeType == TradeType.Buy ? _supertrend.UpTrend.Last(0) : _supertrend.DownTrend.Last(0);

                // Solo modificamos el StopLoss, dejando el TakeProfit sin cambios
                ModifyPosition(position, newStopLoss, position.TakeProfit);
            }
        }

there is a warning:

Warning CS0618: 'Robot.ModifyPosition(Position, double?, double?)' is obsolete: 'Please use new version with Protection Type parameter.' (C:\Users VORGE\Documents\cAlgo\Source\Robots\SuperTrend\SuperTrend SuperTrend.cs, line: 71, column: 17)

How can I fixed? 


@ciprescool7
Replies

firemyst
20 Feb 2025, 23:46

By doing exactly what the warning message tells you to.


@firemyst