I know this must be super basic, but I am not able to make it work.
What I am trying to do is the following: On a daily chart, I want to enter a trade right after the opening for the given day if some condition is met in the past.
I want to execute the trade as soon as the markets opens, but when I run my code it gets executed 1 minute before the market closes instead of 1 minute after the market opens.
The idea would be to execute the code as soon as the markets opens and close it before the markets close for the day.
Here is how I my code:
protected override void Initialize()
{
CalculateOnBarClose = true;
ExitOnClose = true;
Add(PeriodType.Minute, 1);
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 0)
{
if (something])
{
EnterLong(1, 1, "Long: 1min");
}
}
else
{
return;
}
}

Comment