Why does this EA (in early development) not produce an alert, or an error?

Why does this EA (in early development) not produce an alert, or an error?

Manage alerts

Loading saved threads...

Andy Thompson · External communityPost link
External question — Stack Overflow Stack Exchange Author: Andy Thompson Original post: https://stackoverflow.com/questions/65295953 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. #property strict string subfolder = "ipc\\"; int last_read = 0; int t = 0; struct trade_message { int time; // time string asset; // asset string direction; // direction double open_price; // open double stop_price; // open double close_price;// open float fraction; // fraction string comment; // comment string status; // status }; trade_message messages[]; int OnInit() { int FH = FileOpen(subfolder+"processedtime.log",FILE_BIN); if(FH >=0) { last_read = FileReadInteger(FH,4); FileClose(FH); } return(INIT_SUCCEEDED); } void OnTick() { int FH=FileOpen(subfolder+"data.csv",FILE_READ|FILE_CSV, ","); //open file int p=0; while(!FileIsEnding(FH)) { t = StringToInteger(FileReadString(FH)); if(t<=last_read) { break; } do { messages[p].time = t; // time messages[p].direction = FileReadString(FH); // direction messages[p].open_price = StringToDouble(FileReadString(FH)); // open messages[p].stop_price = StringToDouble(FileReadString(FH)); // stop messages[p].close_price = StringToDouble(FileReadString(FH)); // close messages[p].fraction = StringToDouble(FileReadString(FH)); // fraction (?float) messages[p].comment = FileReadString(FH); // comment messages[p].status = FileReadString(FH); // status Alert(messages[p].comment); } while(!FileIsLineEnding(FH)); p++; Alert("P = ",p,"; Array length = ", ArraySize(messages)); } FileClose(FH); last_read = t; FileDelete(subfolder+"processedtime.log"); FH = FileOpen(subfolder+"processedtime.log",FILE_BIN); FileWriteInteger(FH,t,4); FileClose(FH); ArrayFree(messages); } The code is in tick function in order to test it before taking it out to a function. The data.csv file is: Timestamp Asset Direction Price Stop Profit Fraction Comment Status xxx yyy SHORT 13240 13240 13220 0.5 yyy SHORT 13240 - taken half at 13220 and stop to breakeven U xxx yyy SHORT 13240 13262 13040 1.0 55% DP The processedtime.log is not being created.
Quote
Report
Andy Thompson · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Andy Thompson Original post: https://stackoverflow.com/a/65311549 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. So 2 problems, both of my own making. Not skipping the header row, simply remedied by inserting do f = FileReadString(FH); while(!FileIsLineEnding(FH)); after FileOpen() (easier than altering my source for data.csv ), and forgetting about the asset part of my structure, thus ensuring my structures got out of sync with my lines!! Remedied by adding messages[p].asset = FileReadString(FH); between messages[p].time = t and messages[p].direction = FileReadString(FH);
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Andy Thompson Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/questions/65295953 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. #property strict string subfolder = "ipc\\"; int last_read = 0; int t = 0; struct trade_message { int time; // time string asset; // asset string direction; // direction double open_price; // open double stop_price; // open double close_price;// open float fraction; // fraction string comment; // comment string status; // status }; trade_message messages[]; int OnInit() { int FH = FileOpen(subfolder+"processedtime.log",FILE_BIN); if(FH >=0) { last_read = FileReadInteger(FH,4); FileClose(FH); } return(INIT_SUCCEEDED); } void OnTick() { int FH=FileOpen(subfolder+"data.csv",FILE_READ|FILE_CSV, ","); //open file int p=0; while(!FileIsEnding(FH)) { t = StringToInteger(FileReadString(FH)); if(t<=last_read) { break; } do { messages[p].time = t; // time messages[p].direction = FileReadString(FH); // direction messages[p].open_price = StringToDouble(FileReadString(FH)); // open messages[p].stop_price = StringToDouble(FileReadString(FH)); // stop messages[p].close_price = StringToDouble(FileReadString(FH)); // close messages[p].fraction = StringToDouble(FileReadString(FH)); // fraction (?float) messages[p].comment = FileReadString(FH); // comment messages[p].status = FileReadString(FH); // status Alert(messages[p].comment); } while(!FileIsLineEnding(FH)); p++; Alert("P = ",p,"; Array length = ", ArraySize(messages)); } FileClose(FH); last_read = t; FileDelete(subfolder+"processedtime.log"); FH = FileOpen(subfolder+"processedtime.log",FILE_BIN); FileWriteInteger(FH,t,4); FileClose(FH); ArrayFree(messages); } The code is in tick function in order to test it before taking it out to a function. The data.csv file is: Timestamp Asset Direction Price Stop Profit Fraction Comment Status xxx yyy SHORT 13240 13240 13220 0.5 yyy SHORT 13240 - taken half at 13220 and stop to breakeven U xxx yyy SHORT 13240 13262 13040 1.0 55% DP The processedtime.log is not being created.

Cancel quote

Checking account access…
Why does this EA (in early development) not produce an alert, or an error? | Forex.com.bd