Simple question on long/short stoploss
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.
breakermind
08 Aug 2013, 01:16
RE:
iRobot said:
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