For example: After 7 ticks profit, the stop is raised to entry price + 2 ticks, BUT after that, my other stoploss modifications do not appear to be working.
I looked in the message boards and I could not find a clear answer on how to do this. I have looked at the Sample Price Modification Script.
protected override void Initialize()
//PROFIT TARGET AND STOP LOSS
{
SetProfitTarget("", CalculationMode.Ticks, ProfitTarget);
SetStopLoss("", CalculationMode.Ticks, stoplossticks, false);
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
// Condition set 1
if ((myEntryOrder == null)
&& CrossAbove(Close, EMA(LengthMA), 1))
{
myEntryOrder = EnterLongLimit(0, true, DefaultQuantity, Close[0] + SlipTicks * TickSize, "Long Limit");
}
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, stoplossticks);
}
// If a long position is open, allow for stop loss modification
if (Position.MarketPosition == MarketPosition.Long)
{
// Once the price is greater than entry price+trailtrigger, set stop loss to breakeven + trail
if (Close[0] >= (Position.AvgPrice + 7* TickSize))
{
SetStopLoss("", CalculationMode.Price, Position.AvgPrice + 2* TickSize, true);
}
if (Close[0] >= (Position.AvgPrice + 9* TickSize))
{
SetStopLoss("", CalculationMode.Price, Position.AvgPrice + 5* TickSize, true);
}
if (Close[0] >= (Position.AvgPrice + 11* TickSize))
{
SetStopLoss("", CalculationMode.Price, Position.AvgPrice + 7* TickSize, true);
}
}
}

Comment