string Name = "Data\\tradeList.csv"; // name of the CSV file
string readTrade(string csv,
string* tAsset,
string* tType,
float* tLots,
float* tStop
)
{
string nextline = strstr(csv,"\n");
if(nextline) nextline++;
string separator = strstr(csv,",");
if(separator) separator = ",";
else separator = ";";
*tAsset = strtok(csv,separator); //symbol
if(!*tAsset) return nextline;
strtok(0,separator); // expiry
*tType = strtok(0,separator); // action: buy or sell
sscanf(strtok(0,separator),"%f", &tLots); //quantity in standard lots
strtok(0,separator); // order type
sscanf(strtok(0,separator),"%f", &tStop); //aux price
return nextline;
}
function run()
{
set(LOGFILE);
// StartDate = STARTDATE;
LookBack = 0;
if(is(LOOKBACK) || is(TRADING))
return;
if(!file_date(Name))
quit("File not found!");
string content = file_content(Name);
string tAsset = "",tType = "";
float tLots;
float tStop;
while(content) {
content = readTrade(content,&tAsset,&tType,&tLots,&tStop);
printf("\n%s %s %f %f", tAsset, tType, tLots, tStop);
}
}