I made a mistake in the prior code: of course, if TradeIsEntry then returning 4 will lead to a missed entry.
But returning 4 on the first run of a TMF, prevents TMF from running on subsequent ticks and leads to no entries at all ( it does in 2.37.3).
int tmf() {
if (TradeIsNewBar) return 4;
watch("#time=",tod(0));
return 0;
}
function run() {
NumYears=1;
set(LOGFILE, TICKS);
LifeTime=5;
Entry=-3*PIP;
if (NumOpenLong==0)
if (priceClose(0)>priceClose(20) )
enterLong(tmf);
}
produces:
[103: Fri 21-01-08 07:00c] 1.22585/1.22687\1.22581/1.22641 -0.0
Enter Long EUR/USD Entry -0.00030000 at 07:00:00
(EUR/USD::L) Long 1@1.22611 Entry limit
[104: Fri 21-01-08 08:00c] 0000 0 0/0 1.22641/1.22697\1.22329/1.22395 -0.0
(EUR/USD::L) Missed entry 1.2261 after 1 bar