StopOrder after MarketOrder S/L

Created at 18 Dec 2016, 01:18
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!
CO

collinganesh

Joined 14.10.2016

StopOrder after MarketOrder S/L
18 Dec 2016, 01:18


Hello,

What code do I use to place a SellStop Order after the SellOrder S/L is hit? The SellStop Order should be placed placed at the price where the SellOrder was executed.

Kind regards.

if (_MA_cross_down && shortPosition == null)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, Symbol.NormalizeVolume(Volume), label, StopLoss, TakeProfit);

            }

            
            
            
            if (_MA_cross_down && shortPosition == null)
            {
                double targetPrice = Symbol.Ask + PipsAway * Symbol.PipSize;
                PlaceStopOrder(TradeType.Buy, Symbol, Volume2, targetPrice, label_2, StopLoss, TakeProfit);
            }



        }

        private void PositionClosed(PositionClosedEventArgs args)
        {
            var pos = args.Position;
            if (pos.Label == label && pos.NetProfit > 0)
            {
                foreach (var order in PendingOrders)
                {
                    if (order.Label == label_2 && order.OrderType == PendingOrderType.Stop)
                    {
                        CancelPendingOrder(order);
                    }
                }
            }

        }

 


@collinganesh