How can I use for break-even calculation the IOrder average price instead of Position.AvgPrice.
I tried the following changes but it does not work
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
private IOrder Entry = null;
protected override void OnBarUpdate()
{
// Condition set 1
if (Position.MarketPosition == MarketPosition.Flat)
{
EnterLong(DefaultQuantity, "Entry");
IOrder Entry = EnterLong("Entry");
Variable0 = Close[0] + BreakEvenTrigger * TickSize;
Variable1 = Close[0] + InitialStopDistance * TickSize;
Variable2 = 0;
Variable3 = 0;
}
// Condition set 2
if (Position.MarketPosition == MarketPosition.Long
&& Variable2 == 0)
{
Variable0 = Entry.AvgFillPrice + BreakEvenTrigger * TickSize;
Variable2 = 1;
}
// Condition set 3
if (Position.MarketPosition == MarketPosition.Long
&& Close[0] >= Variable0
&& Variable3 == 0)
{
Variable1 = Entry.AvgFillPrice;
DrawDiamond("My diamond" + CurrentBar, false, 0, Low[0] + -3 * TickSize, Color.DarkCyan);
Variable3 = 1;
}
// Condition set 4
if (Position.MarketPosition == MarketPosition.Long)
{
ExitLongStop(Variable1, "Exit", "Entry");

Comment