{
#region Variables
private bool OneBarSinceExit = true;
#endregion
protected override void Initialize()
{
CalculateOnBarClose = false;
SetProfitTarget("Long 1a", CalculationMode.Ticks, 5);
SetProfitTarget("Short 1a", CalculationMode.Ticks, 5);
}
protected override void OnBarUpdate()
{
if (CurrentBar < 1)
return;
if (BarsSinceExit("Long 1a") > 1)
OneBarSinceExit = true;
if (BarsSinceExit("Short 1a") > 1)
OneBarSinceExit = true;
if (OneBarSinceExit = true && SMA(9)[0] > SMA(20)[0])
EnterLong(1, "Long 1a");
OneBarSinceExit = false;
if (OneBarSinceExit = true && SMA(9)[0] < SMA(20)[0])
EnterShort(1, "Short 1a");
OneBarSinceExit = false;
}
#region Properties
#endregion
}
}

Comment