// 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
elseif (Position.MarketPosition == MarketPosition.Long)
{
// Once the price is greater than entry price+10 ticks, set stop loss to breakeven
if (Close[0] > Position.AvgPrice + 10 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
Print("Code has entered into a break-even situation");
}
}
// If a long position is open, once the price is greater than entry price+25 ticks, set stop loss profit of 10
elseif (Position.MarketPosition == MarketPosition.Long)
{
if (Close[0] > Position.AvgPrice + 25 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice + 10);
Print("Code has entered into a minimum 10 PIP profit situation");
}
}
// If a long position is open, // Once the price is greater than entry price+50 ticks, set stop loss profit of 25
elseif (Position.MarketPosition == MarketPosition.Long)
{
if (Close[0] > Position.AvgPrice + 50 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice + 25);
Print("Code has entered into a minimum 25 PIP profit situation");
}
Comment