what is wrong
what is wrong
12 May 2016, 13:20
protected void UpdateTrailingStops()
{
if (!EnableTrailingStop)
return;
var positions = Positions.FindAll(label);
if (positions == null)
return;
foreach (var position in positions)
{
if (position.Pips >= TrailingStart)
{
if (position.TradeType == TradeType.Buy)
{
var newStopLoss = Symbol.Bid - TrailingStop * Symbol.PipSize;
if (position.StopLoss < newStopLoss)
ModifyPosition(position, newStopLoss, null);
}
else if (position.TradeType == TradeType.Sell)
{
var newStopLoss = Symbol.Ask + TrailingStop * Symbol.PipSize;
if (position.StopLoss > newStopLoss)
ModifyPosition(position, newStopLoss, null);
}
}
}
}
protected void MoveToBreakEven()
{
if (!EnableBreakEven)
return;
var positions = Positions.FindAll(label);
if (positions == null)
return;
foreach (var position in positions)
{
if (position.Pips >= BreakEvenPips)
{
if (position.TradeType == TradeType.Buy)
{
var newStopLoss = Symbol.Bid - BreakEvenGain * Symbol.PipSize;
if (position.StopLoss < newStopLoss)
ModifyPosition(position, newStopLoss, null);
}
else if (position.TradeType == TradeType.Sell)
{
var newStopLoss = Symbol.Ask + BreakEvenGain * Symbol.PipSize;
if (position.StopLoss > newStopLoss)
ModifyPosition(position, newStopLoss, null);
}
}
}
}
whis.gg
12 May 2016, 13:53
Not tested.
@whis.gg