Upon entry:
- All orders share the same fixed stop loss
Upon hitting profit target1
- Set trailing stops to 20 pips for the 2 remaining legs
Upon hitting profit taregt 2
- Set the trailing stop to 50 pips for the 1 remaining leg
I'm trying to do that via the following code. Please note that I set EntryHandling = EntryHandling.UniqueEntries.
This is a snippet from OnBarUpdate()
if( bullish && Position.MarketPosition != MarketPosition.Long )
{
EnterLong(Units1, TARGET1);
EnterLong(Units2, TARGET2);
EnterLong(Units3, TARGET3);
SetStopLoss(TARGET1, CalculationMode.Ticks, InitialStop, false);
SetTrailStop(TARGET2,CalculationMode.Ticks, InitialStop, false);
SetTrailStop(TARGET3,CalculationMode.Ticks, InitialStop, false);
}
protected override void OnOrderUpdate(IOrder order)
{
if( order.OrderAction == OrderAction.BuyToCover || order.OrderAction == OrderAction.Sell )
{
switch(order.Name)
{
case TARGET1:
SetTrailStop(TARGET2,CalculationMode.Ticks, Trailing, false);
SetTrailStop(TARGET3,CalculationMode.Ticks, Trailing, false);
break;
case TARGET2:
SetTrailStop(TARGET3,CalculationMode.Ticks, TrailingFinal, false);
break;
default:
break;
}
}
}

Comment