I would like to write values of ActionZone to a file and took a stab at the following script:
ref = ActionZones(&s1, &r1, &s2, &r2);
if (ref == true) {
file_write("C:\Users\AZ\BDPM.txt",open);
file_write("C:\Users\AZ\BDPM.txt",s1);
file_write("C:\Users\AZ\BDPM.txt",s2);
file_write("C:\Users\AZ\BDPM.txt",r1);
file_write("C:\Users\AZ\BDPM.txt",r2);
}
Obviously, it wrote values for each bar with update. Is there a way to stop writing to the file after the first bar of the day is printed?
thanks,
Writing to file
-
- Posts: 10
- Joined: Mon Sep 25, 2017 4:44 pm
- Contact:
Re: Writing to file
Hi,
Yeah, just change the "if" block to only trigger when you are on the first bar of the day. Do it like this...
Regards,
Earik
Yeah, just change the "if" block to only trigger when you are on the first bar of the day. Do it like this...
Code: Select all
ref = ActionZones(&s1, &r1, &s2, &r2);
if ((ref == true) and (day!=day[1])) {
file_write("C:\Users\AZ\BDPM.txt",open);
file_write("C:\Users\AZ\BDPM.txt",s1);
file_write("C:\Users\AZ\BDPM.txt",s2);
file_write("C:\Users\AZ\BDPM.txt",r1);
file_write("C:\Users\AZ\BDPM.txt",r2);
}
Earik
-
- Posts: 10
- Joined: Mon Sep 25, 2017 4:44 pm
- Contact:
Re: Writing to file
Thanks Earik; while the solution fixes printing to the file for every bar, it prints for every day on the chart. I was thinking while loop for recent day, but couldn't make it work; would appericiate if you can provide another pointer as well.
Re: Writing to file
So you only want it to print if the day is today? You can use the currentday/currentmonth/currentday keywords to check for that. Do it like this:
Hope that helps!
Earik
Code: Select all
ref = ActionZones(&s1, &r1, &s2, &r2);
if ((ref == true) and (day!=day[1])) {
#build a timestamp for today
today_timestamp = currentyear*10000 + currentmonth*100 + currentday;
#build a timestamp for the day on the chart
chart_timestamp = year*10000 + month*100 + day;
#only write to the file if its the current day
if (today_timestamp == chart_timestamp) {
file_write("C:\Users\AZ\BDPM.txt",open);
file_write("C:\Users\AZ\BDPM.txt",s1);
file_write("C:\Users\AZ\BDPM.txt",s2);
file_write("C:\Users\AZ\BDPM.txt",r1);
file_write("C:\Users\AZ\BDPM.txt",r2);
}
}
Earik
Who is online
Users browsing this forum: No registered users and 37 guests