I'm basically trying to avoid an entry if there was already an entry closed in the previous bar. So just to be sure I decided the avoid entries at least for 3 bars after the last trade so I made this code:
Code: Select all
if (EntriesToday(Date) > 0 = true) then begin
if barssinceexit(1) > 3 then canEntry= true else canEntry= false;
if barstatus = 2 then print("barssinceexit(1) = ", barssinceexit(1));
end;
if marketposition = 0 and canEntry then begin
The problem is that by adding "canEntry" in the " if marketposition = 0 and canEntry then begin" the strategy doesn't perform any trade. By removing canentry the backtest is showing 731 trade.
Ok so I tryied to print barssinceexit(1) and it work!!!!! It is correclty showing values in the Output as this exampe:
Code: Select all
barssinceexit(1) = 0.00
barssinceexit(1) = 1.00
barssinceexit(1) = 2.00
barssinceexit(1) = 3.00
barssinceexit(1) = 4.00
barssinceexit(1) = 5.00
barssinceexit(1) = 6.00
barssinceexit(1) = 7.00
barssinceexit(1) = 8.00
barssinceexit(1) = 9.00
barssinceexit(1) = 10.00
barssinceexit(1) = 11.00
barssinceexit(1) = 12.00
barssinceexit(1) = 13.00
So if I'm able to PRINT it then barssinceexit(1) HAS a value and why my code is basically never doing a trade? --------> Why canEntry is always false?
Any help would be appreciated.
Thanks
David