Here is the demo script :
function run () {
if (is(INITRUN) ) {
set(LOGFILE);
set(PLOTNOW);
Verbose =3;
NumYears=1;
}
vars rsi = series(RSI(seriesC(),5), 10);
EntryTime=1;
Entry = -1.5*PIP;
Lots=1;
if (rsi[0]>70 and rsi[1]<70) {
exitLong();
if (WinStreakShort>5) Lots=-1;
enterShort();
}
else
if (rsi[0]<30 and rsi[1]>30) {
exitShort();
if (WinStreakLong>5) Lots=-1;
enterLong();
}
}
. After several first real trades, phantom trades are subsequently "missed" - despite price penetrating the entry limit level, e.g.:
[525: Wed 21-02-03 09:00c] 1.20382/1.20428\1.20317/1.20320 -0.00003
Exit EUR/USD 0
Enter Long EUR/USD Entry -0.00015000 at 09:00:00
(EUR/USD::l) Long 1@1.20305 Entry limit
[526: Wed 21-02-03 10:00] -3.21 0 24/17 1.20320/1.20325\1.20097/1.20235 -0.00003
(EUR/USD::l) Missed entry 1.2031 after 1 bar
The problem disappears, if either:
EntryTime is set to 2 :
[525: Wed 21-02-03 09:00c] -2.84 +1.61 28/20 1.20382/1.20428\1.20317/1.20320 -0.00003
Exit EUR/USD 0
Enter Long EUR/USD Entry -0.00015000 at 09:00:00
(EUR/USD::L) Long 1@1.20305 Entry limit
(EUR/USD::L) Entry limit 1.20305 hit by 1.20097 at 09:00:00
[EUR/USD::L52606] Long 1@1.20296 at 09:00:00
Com 0.0570 Mrg 39.37 Net 3
[526: Wed 21-02-03 10:00] -2.84 -1.64 27/22 1.20320/1.20325\1.20097/1.20235 -0.00003
, or when trades are not "exited" before entry (i.e. exitLong()/Short() ) are commented out.