No trades in backtest when reading from textfile

I have hired a programmer at Upwork to program a system to read a textfile that takes trades after news. The problem we cant solve is that the system reads the file (takes about 12 seconds) but doesnt show any trades when backtesting or scanning.

The textfile looks like this,
Date, Ticker, news
2019-01-15, AAPL,b
2019-01-16, AGEN,a

The b means that the news came out before market open, then I want to buy/short at close at the same day 2019-01-15.
The a means that the news came out after market close the 16th, then I want to buy/short at close the next day 2019-01-17.

Following what it says in this link didnt help

I would be superhappy if someone can guide me in the right direction to solve this.


Yfile = "C:\\Users\\Johan Widell\\Documents\\Trading\\Nyheter.csv"; // change this to real location of your data file

Ydt = DateTime();

// Initialize variables
Buy = Sell = 0; 
possize = 0;
fh = fopen( Yfile, "r" );

if( fh )
     while( ! feof( fh ) )
         line = fgets( fh );
         // get the ticker symbol from the file
         trade_datetime = StrToDateTime( StrExtract( line, 0 ) );
         sym = StrExtract( line, 1 );
         Ynewstype = StrExtract( line, 2 );
         newbuy = (Ydt == trade_datetime AND Ynewstype == "B") OR (Ref(Ydt, -1) == trade_datetime AND Ynewstype == "A");
         Buy = newbuy AND Name() == sym ; 
         Sell = Ref(Buy, -1);
         newshort = (Ydt == trade_datetime AND Ynewstype == "B") OR (Ref(Ydt, -1) == trade_datetime AND Ynewstype == "A");
         Short = newbuy AND Name() == sym ; 
         Cover = Ref(Short, -1);

     fclose( fh );
     Error( "ERROR: file can not be open" );

So your cheap "programmer" from I...a(?) who doesn't know how to code and has never heard of debugging (I didn't even need debugging to see the flaw) is trash and we here are supposed to do your "programmer" job while he gets paid for it.

I hope you are kidding.

(Or are you the programmer from upwork yourself who doesn't know how to proceed?)

BTW, how to backtest from file is shown here at KB already ("your" upper code contains parts of it. So you or your "programmer" have looked at that one already).

BTW #2, below is result list after fixing "your code" from post #1 (Just to show you that it is not AmiBroker fault but indeed your programmer is trash (aka not worth any money)) and the way you want it... Buy and Short at same time.


As I mentioned already above... use debugging techniques (since you both seem to have never heard of it).
If you guys are still helpless then send PM.
But e.g. I will definitely not tell your "programmer" how to do his job.