I am facing the following problem when writing a simple strategy.
When the strategy starts running, it enters and exit by 1 unit. However, as the strategy progresses the entered an exited units increased progressively.
For example, when I started the strategy at 8 am, every single trade is only 1 contract. As time progresses (let say till 11am), a single trade will become 10 contracts. At 1pm, a single trade then become 15 contracts.
Is there anyway to standardise to 1 contract for all trade? The code is as below.
Thanks!

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>
protected override void OnBarUpdate()
{
// Condition set 1
if (Close[0] > Close[1]
&& Close[1] > Close[2])
{
EnterLong(DefaultQuantity, "");
ExitShort("", "");
}
// Condition set 2
if (Close[0] < Close[1]
&& Close[1] < Close[2])
{
EnterShort(DefaultQuantity, "");
ExitLong("", "");
}

Comment