SamplePriceModification from support. The idea is to has a 5 tick stop which is changed
to breakeven after a move of 10 ticks. The code is below. It doesn't work at all.
protected override void OnBarUpdate()
{
// Resets the stop loss to the original value when all positions are closed
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Ticks, stoplossticks);
}
else if (Position.MarketPosition == MarketPosition.Long)
{
if (Close[0] > Position.AvgPrice + 10 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
else if (Position.MarketPosition == MarketPosition.Short)
{
if (Close[0] < Position.AvgPrice - 10 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
}
// Entry Condition: see below
if (Close[0]>Close[1]&& (Median [0]>Median[1])&& enteredLong==false)
{
EnterLong();
}
if (Close[0]<Close[1]&& (Median [0]<Median[1])&& enteredShort==false)
{
EnterShort();
}
Comment