i dont know if im crazy or just not able to think logic.
my strategy is perfectly handling my long stops but not my short stops and i have no idea why. if someone could help me pls
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
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);
}
// 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+10 ticks, set stop loss to breakeven
if (High[0] > Position.AvgPrice + breakeventicks * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice - 3);
}
// Once the price is greater than entry price+10 ticks, set stop loss to breakeven
if (High[0] > Position.AvgPrice + plusstop1ticks * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice + 2);
}
// Once the price is greater than entry price+10 ticks, set stop loss to breakeven
if (High[0] > Position.AvgPrice + plusstop2ticks * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice + 5);
}
}
// 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+10 ticks, set stop loss to breakeven
if (Low[0] < Position.AvgPrice - breakeventicks * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice + 3);
}
// Once the price is greater than entry price+10 ticks, set stop loss to breakeven
if (Low[0] < Position.AvgPrice - plusstop1ticks * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice - 2);
}
// Once the price is greater than entry price+10 ticks, set stop loss to breakeven
if (Low[0] < Position.AvgPrice - plusstop2ticks * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice - 5);
}
}
Comment