Allrigth, then I rewrite the script as follows and apply it to the EURUSD that has no problem of history data.


function run()
{
BarPeriod = 1440;

vars A1 = series(priceClose(2));
vars A2 = series(priceClose(1));
vars A3 = series(price(0));
//Vlr = 10*PIP


if (A1[0] < A2[0] and A3[0] < A1[0]) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]) enterShort();

Stop = 30*PIP;
TakeProfit = 500*PIP;
//ExitTime = 1;

}

This gives the following results:


A1,A2,A3 Ar62% compiling...............
Error 055: EUR/USD 2014 price history missing
BackTest: A1,A2,A3 Ar62% EUR/USD 2009..2014
Profit 173$ MI 3$ DD 61$ Capital 60$
Trades 176 Win 18% Avg +12.9p Bars 3
AR 74% PF 1.48 SR 0.75 UI 13.3% Error 54%

That is, an annual return of 74%, which is not a big deal though the script can be refined and get better and more robust results. It is just an exemple for the sake of the discussion here. The main thing is that the re-Test problem seem to have been solved. I re-tested many times and now it gives results every time, so I assume that the script has now no bug, isn't it?