Here is the code below this is my question:
protected override void OnBarUpdate()
{
// Only trade between 7:45 AM and 1:45 PM
if (ToTime(Time[0]) >= 104500 && ToTime(Time[0]) <= 124500)
{
if (CrossAbove(SMA(Fast), SMA(Slow), 1))
{
EnterLong();
//Print("Enter Long");
}
else if (CrossBelow(SMA(Fast), SMA(Slow), 1))
{
EnterShort();
//Print("Enter Short");
}
//Print("Enter Short"); // If I only allow this line to run after time range is entered, then we don't crash.
}
}
1. Market replay, doesn't really matter the data, but June 1 is what I used.
2. Dom was open, Strategy tab from control panel was in focus, and of course market replay. Nothing else open.
3. I started the replay at 9:16am, and at about 10:55 or so, the program froze. It is around the 10:45am mark or near the Begin of my time range. So in other words, when we branch into the loop, boink.
4. I tried to get rid of the indicators and just said Print blah blah and that loop worked fine. So it has something to do with putting the indicators inside the time frame.
Am I just doing something really wrong like should I instantiate the SMA outside of the loop or something or does that not matter? I forgot, so forgive me if I am asking a noob question. But I don't think it should be crashing.
Thanks,
r2kTrader

Comment