After many hours of scratching my head, I can't figure out why I'm seeing these trades occur at the prices they do. Check out the trades at 5am on the 16th and 4am on the 20th. Both have been set to enter long at limit 1 tick above the previous day's high. As you can see, they are entering at this price even though the actual price never reached these levels. It happens in many other places too. The code is below. Any ideas?
private int quant = 10000;
private double insidelow = 0;
private double trailstop = 0;
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
Add(DBollinger(2, 20));
CalculateOnBarClose = false;
ExitOnClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (Position.MarketPosition == MarketPosition.Flat)
{
if (Low[1] <= Bollinger(2, 20).Lower[1] + 1 * TickSize)
{
if (High[0] < High[1] && Low[0] > Low[1])
{
EnterLongLimit(quant, High[0] + 1 * TickSize, "GoLong");
insidelow = Low[0];
trailstop = 0;
ExitLongStop(insidelow - 3 * TickSize,"InitialStop", "GoLong");
}
}
}
if (Position.MarketPosition == MarketPosition.Long)
{
if (Close[0] > SMA(20)[0])
{
if (trailstop < SMA(20)[0])
{
trailstop = SMA(20)[0];
}
ExitLongStop(trailstop - 3 * TickSize,"TrailStop", "GoLong");
}
ExitLongStop(insidelow - 3 * TickSize,"InitialStop", "GoLong");
}
}
Comment