Long Positions are entering correctly on this strategy but not Shorts?
Positions are supposed to enter at the desired time.
Am I doing something incorrectly?
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class Timetest : Strategy
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#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 = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (ToTime(Time[0]) > ToTime(8, 0, 0)
&& ToTime(Time[0]) < ToTime(8, 20, 0))
{
EnterLong(100000, "Long");
}
// Condition set 2
if (Position.Quantity > 0
&& ToTime(Time[0]) > ToTime(10, 20, 0))
{
ExitLong("", "");
}
// Condition set 3
if (ToTime(Time[0]) > ToTime(11, 0, 0)
&& ToTime(Time[0]) < ToTime(11, 20, 0))
{
EnterShort(100000, "Short");
}
// Condition set 4
if (Position.Quantity < 0
&& ToTime(Time[0]) > ToTime(11, 40, 0))
{
ExitShort("", "");
}
}
Comment