I notice the code is excute more frequent even I set CalculateOnBarClose=true. Is anyone know what I did wrong? Below is the test strategy.
#region Variables
// Wizard generated variables
private int ticksBeforeFiringOrder = 10; // Default setting for TicksBeforeFiringOrder
// User defined variables (add any user defined variables below)
private int nbar=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()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
Print ("OnBarUpdate: CurrentBar"+CurrentBar.ToString()+ "; nbar="+nbar.ToString()+"; Close[0]="+Close[0].ToString()+ "; Close[1]="+Close[1].ToString());
if (Close[0] > Close[1])
{
EnterLong (10, "TLong");
}
if (Position.MarketPosition == MarketPosition.Long)
{
if (nbar > 10) {
nbar=0;
ExitLong();
}
else
nbar++;
}
}
Comment