Simple question on long/short stoploss

Created at 07 Aug 2013, 22:30
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!
IR

iRobot

Joined 17.02.2013

Simple question on long/short stoploss
07 Aug 2013, 22:30


Hi,

this is my stoploss/takeprofit condition. Stoploss must have Lower value for Long position and Upper value for Short position. I don't know how to implement that. In a given code stoploss has only one codition when position is opened. 

         protected override void OnPositionOpened(Position openedPosition)
        {
            _position = openedPosition;

            double? stopLoss = LowerValue;
            double? takeProfit = _position.EntryPrice + Symbol.PipSize*TakeProfit;
 

            Trade.ModifyPosition(openedPosition, stopLoss, takeProfit);

        }

 

How could I have Upper and Lower stop loss depending if position is Short or Long.

 

Thanks.


@iRobot
Replies

breakermind
08 Aug 2013, 01:16

RE:

iRobot said:

Hi,

this is my stoploss/takeprofit condition. Stoploss must have Lower value for Long position and Upper value for Short position. I don't know how to implement that. In a given code stoploss has only one codition when position is opened. 

         protected override void OnPositionOpened(Position openedPosition)
        {
            _position = openedPosition;

            double? stopLoss = LowerValue;
            double? takeProfit = _position.EntryPrice + Symbol.PipSize*TakeProfit;
 

            Trade.ModifyPosition(openedPosition, stopLoss, takeProfit);

        }

 

How could I have Upper and Lower stop loss depending if position is Short or Long.

 

Thanks.

Hi,

Prawdopodobnie co? takiego je?eli dobrze zrozumia?em i  mo?na stawia? stopllos poni?ej warto?ci otwarcia pozycji,

je?eli nie to wtedy stop los zast?pi? trzeba takeprofitem

         protected override void OnPositionOpened(Position openedPosition)
        {

            position = openedPosition;

            foreach (var position in Account.Positions)
            {
            
        double LowerValue = 10;
        double UpperValue = 20;

     if(position.TradeType == TradeType.Buy){
            
        double? stopLoss = position.EntryPrice - Symbol.PipSize*LowerValue;
            double? takeProfit = position.EntryPrice + Symbol.PipSize*TakeProfit;

        Trade.ModifyPosition(position, stopLoss, takeProfit);            
            }

       if(position.TradeType == TradeType.Sell){
            double? stopLoss = position.EntryPrice + Symbol.PipSize*UpperValue;
            double? takeProfit = position.EntryPrice - Symbol.PipSize*TakeProfit;
            
        Trade.ModifyPosition(position, stopLoss, takeProfit);
            }

            }


        }

 

je?eli czego? nie pomyli?em nie testowa?em

Pozdrawiam

Ps. if You do not understant

http://translate.google.com/

language PL

 


@breakermind

iRobot
08 Aug 2013, 09:16

Thanks. This is same logic I thought about. Will try it.


@iRobot