Hi!
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
http://www.amibroker.com/kb/2014/11/10/troubleshooting-procedure-when-backtest-shows-no-trades/
I would be superhappy if someone can guide me in the right direction to solve this.
/Thanks
Johan
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 );
}
else
{
Error( "ERROR: file can not be open" );
}