Can someone check this code... does this look right?
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, 50);
}
// If a long position is open, allow for stop loss modification to breakeven
else if (Position.MarketPosition == MarketPosition.Long)
{
// Once the price is greater than entry price by 8 ticks, set stop loss to BE + 2
if (GetCurrentBid() > Position.AvgPrice + 8 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice + 2 * TickSize);
}
}
else if (Position.MarketPosition == MarketPosition.Short)
{
// Once the price is less than entry price by 8 ticks, set stop loss to BE + 2
if (GetCurrentBid() < Position.AvgPrice - 8 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice - 2 * TickSize);
}
}

Comment