- reverse when the ATR based stop is hit.
- reversal also has a stop based on the ATR.
- reverse only the one time until the initial entry criteria is met again.
- need this reversal order to exit when a certain criteria is hit, say MACD fast length crest/trough breakover.
#region Stoploss reset, ATR Stop set, & Breakeven (BE)
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, StopLoss);
//Set ATR Stop in ticks
StopLoss = Convert.ToInt32(Math.Round( ATR(ATRStopPeriod)[0] * ATRStopMulti / TickSize));
}
// 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 +BETrigger ticks, set stop loss to breakeven + 1
if (Close[0] > Position.AvgPrice + BETrigger * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice + 1 * TickSize);
}
}
// If a short position is open, allow for stop loss modification to breakeven
else if (Position.MarketPosition == MarketPosition.Short)
{
// Once the price is greater than entry price +BETrigger ticks, set stop loss to breakeven + 1
if (Close[0] < Position.AvgPrice - BETrigger * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice - 1 * TickSize);
}
}
#endregion

Comment