TakeProfit % and StopLoss %
            
                 17 Jan 2017, 18:14
            
                    
Hi
I need help for settin StopLoss% and TakeProfit%.My code not working:
private void ClosePosition(TradeType tradeType)
        {
            bool hasNeededPosition = Positions.Any(position => position.Label == StrategyLabel && position.TradeType == tradeType);
            if (!hasNeededPosition)
            {
                double SLpips = MarketSeries.Close.LastValue * StopLossPcnt * 0.01 / Symbol.TickSize;
                double TPpips = MarketSeries.Close.LastValue * TakeProfitPcnt * 0.01 / Symbol.TickSize;
                ExecuteMarketOrder(tradeType, Symbol, (long)Volume, StrategyLabel, SLpips, TPpips);
            }
        }
        private void OpenPosition(TradeType tradeType)
        {
            foreach (var position in Positions)
            {
                if (position.Label == StrategyLabel && position.TradeType == tradeType)
                {
                    //Trade.Close(position);
                    ClosePosition(position);
                }
            }
        }
        protected override void OnPositionOpened(Position openedPosition)
        {
            position = openedPosition;
        }
        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}
