My entry is at the bar close but exit it at 10 PT profit.(40 ticks).
I have this code but it exists at the close of the candle. Why?
First entry is correct : 17542.50 but exit should have been at 17552.50. Instead it exited at 15557.75. Why?
Here is the code:
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
// Set 1
if (Position.MarketPosition == MarketPosition.Flat)
{
MoveToBE = false;
}
if (CurrentBars[0] < 1)
return;
// Set 2
if ((CONDITION FOR LONG)
{
EnterLong(Convert.ToInt32(DefaultQuantity), @"L");
MoveToBE = false;
}
// Set 3
if ((Position.MarketPosition == MarketPosition.Long)
&& (Close[0] >= (Position.AveragePrice + (40 * TickSize)) ))
{
ExitLong(Convert.ToInt32(DefaultQuantity), @"LPT", @"L");
}
}

Comment