Hello Martin,
The reason that your exit trades never occur on the same bar as an entry trade is because of the else statement at line 67.
Your conditional if() statement that allows an entry trade to occur when Breakout is true will not allow the exit conditions to evaluate on the same bar because they are inside an else block that will only evaluate when Breakout is false. In back testing, the formula only executes once per bar. Therefore, the else block is never evaluated on the same bar where the entry trades occur.
Delete or comment out the else statement on line 67 and run the back test. You will then see some exit trades occur on the same bar as the entry trade.
The reason that your exit trades never occur on the same bar as an entry trade is because of the else statement at line 67.
PHP Code:
if (Breakout) {
// entry trades
}
else // line 67
{
// exit trades
}
Delete or comment out the else statement on line 67 and run the back test. You will then see some exit trades occur on the same bar as the entry trade.
Comment