So I am exporting my trades to a text (csv) file... Amibroker lists trades by date with the exit date on the same line. I want to list trades by Date.. showing BUYS and SELLS on that date...the code below, I successfully created the txt (csv) file to export BUYS by date and SELLS by date... however I need to now sort the text file by DATE,.... so it shows buys and sells be date... is there a way to fopen a txt file and sort by column(0) and save the text file?
Thanks
Brian
fh = fopen( "C:\\TESTOUTPUT\\TEST77.csv", "w");
//fputs("Symbol,Name,Entry Date,Profit,Bars,ExitDate",fh);
//fputs("\n",fh);
for ( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
{
EntryIndex = LastValue( ValueWhen( trade.EntryDateTime == Dates,Indices ) );
ExitIndex = LastValue( ValueWhen( trade.ExitDateTime == Dates,Indices ) );
y=Year(); m=Month(); d=Day();
exENTERDATE = StrFormat("%02.0f-%02.0f-%02.0f,", y[ entryindex ], m[ entryindex ], d[ entryindex ] );
exExitDATE = StrFormat("%02.0f-%02.0f-%02.0f,", y[ exitindex ], m[ exitindex ], d[ exitindex ] );
exSYMBOL = TRADE.Symbol;
exNAME = TRADE.FullName();
exPROFIT = Prec(trade.GetPercentProfit,1);
exBARS = trade.BarsInTrade;
exEntryPrice = trade.EntryPrice;
// this code will export trades in the same format as the backtest window (I DO NOT WANT THIS)
//fputs(exEnterDate + exExitDate + exsymbol + "," + exname + "," + exEntryPrice + "," + exBars + "," + enDate2 + "," + exDate2,FH);
//fputs("\n",FH);
// *******this will export trades - BUY trades and SELL Trades on thier own line
fputs(exEnterDate + "BUY," + exsymbol + "," + exname + "," + exEnterDate + "--,--",FH);
fputs("\n",FH);
fputs(exExitDate + "SELL," + exsymbol + "," + exname + "," + exEnterDate + exBars + "," + exProfit ,FH);
fputs("\n",FH);
}
fclose(FH);