[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] AFL File operations - writing trade data to disk



PureBytes Links

Trading Reference Links




I am trying to write data to disk with trade 
details - equity name, buy/sell, time etc.
 
Debugging with EOD version to avoid confusion with 
live data stream.
 
Every time I click on a bar, the selected data is 
written to disk correctly, but is written multiple times. See attached 
file.
 
Appreciate any code review ...
 
Thanks
 
Ara
 

// File operations
// Create text file and save all trade signals<FONT 
size=1>
function DiskDataSave(Trade)
{
fh = fopen(<FONT 
color=#ff00ff size=1>"tradesignals.txt",<FONT 
color=#ff00ff size=1>"a"); <FONT color=#008000 
size=1>//open 
file
if (fh)
{
fputs(Trade + <FONT color=#ff00ff 
size=1>"\n",fh); <FONT color=#008000 
size=1>// write 
data
fclose(fh);
//printf("file opened OK"); 
}
else
{
//printf("Error opening file"); 
"";
}
}
Buy_OK = SelectedValue<FONT 
size=1>(Buy_Signal);
Sell_OK = SelectedValue<FONT 
size=1>(Sell_Signal);
Short_OK = SelectedValue<FONT 
size=1>(Short_Signal);
Cover_OK = SelectedValue<FONT 
size=1>(Cover_Signal);
//Diagnostic printout
"";
"buy " +<FONT color=#0000ff 
size=1>WriteVal(Buy_OK);<FONT color=#ff00ff 
size=1>
"sell" +<FONT color=#0000ff 
size=1>WriteVal(Sell_OK);<FONT color=#ff00ff 
size=1>
"short " +<FONT color=#0000ff 
size=1>WriteVal(Short_OK);<FONT color=#ff00ff 
size=1>
"cover " +<FONT color=#0000ff 
size=1>WriteVal(Cover_OK);<FONT color=#800000 
size=1>
if (DiskSave) // 
Disk Save feature is turned on
{
if (Buy_OK OR Sell_OK OR Short_OK 
OR Cover_OK) // proccess if any signal 
is present
{
for (i =<FONT color=#ff00ff 
size=1>1; i<=<FONT color=#ff00ff 
size=1>4; i++)
{Trade = "xx"<FONT 
size=1>;
if (Buy_OK) 
{Trade = "Buy"<FONT 
size=1>;}
else{
if (Sell_OK) 
{Trade = "Sell"<FONT 
size=1>;}
else{
if (Short_OK) 
{Trade = "Short"<FONT 
size=1>;}
else{
if (Cover_OK) {Trade = <FONT color=#ff00ff 
size=1>"Cover";}
}}}
if (trade != <FONT color=#ff00ff 
size=1>"xx"); // if trade 
signal exists proccess
"trade " + Trade;
{
StringValue = Name() + 
" " + Trade + <FONT 
color=#ff00ff size=1>" " + <FONT color=#0000ff 
size=1>Date() + " 
" + TimeNum<FONT 
size=1>() + " " 
+ WriteVal(<FONT 
color=#0000ff size=1>LastValue(Close));
DiskDataSave(StringValue);
}
} // end loop
} // end if
} // end if 
DiskSave






Yahoo! Groups Sponsor


  ADVERTISEMENT 









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




Issue Type   Date     Time   Price

AZO  Sell  10/31/2003  0    80.250
AZO  Sell  10/31/2003  0    80.250
AZO  Sell  10/31/2003  0    80.250
AZO  Sell  10/31/2003  0    80.250
AZO  Sell  10/31/2003  0    80.250
AZO  Sell  10/31/2003  0    80.250
AZO  Sell  10/31/2003  0    80.250
AZO  Sell  10/31/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250
AZO  Buy  9/18/2003  0    80.250