How to generate log file in TSII?

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

How to generate log file in TSII?

Postby before2012 » Tue Apr 16, 2013 9:53 am

I tried to write log files in my code. It works under diibagger but failed when I put my code in TSII. There's no log file generated, is this a restriction of TSII?
before2012
 
Posts: 15
Joined: Fri Aug 26, 2011 12:57 am

Re: How to generate log file in TSII?

Postby sunshine » Wed Apr 17, 2013 2:57 am

Could you please provide a code snippet on how you write the data to file?
We have checked the issue with the Input and Output Facilities. It works.
sunshine
 

Re: How to generate log file in TSII?

Postby before2012 » Wed Apr 17, 2013 8:08 am

sunshine wrote:Could you please provide a code snippet on how you write the data to file?
We have checked the issue with the Input and Output Facilities. It works.


here's the snippet:
--[[
Logging.
]]
local __log_path = string.gsub(d-e-b-u-g.getinfo(1,"S").source,"^(.+\\)[^\\]+$", "%1");
function log(str)
logname='log'..os.date('%Y%m%d')
local file = assert(io.open(__log_path .. logname, "a"));
local record = os.date() .. " " .. str;
--print(record);
file:write(record .. "\n");
end
before2012
 
Posts: 15
Joined: Fri Aug 26, 2011 12:57 am

Re: How to generate log file in TSII?

Postby sunshine » Fri Apr 19, 2013 4:02 am

Since the following line uses some internal variables, we have replaced the path to another and double-checked your code. It works without error.
Code: Select all
local __log_path = string.gsub(d-e-b-u-g.getinfo(1,"S").source,"^(.+\\)[^\\]+$", "%1");

So, it looks like the issue is related with this line.
sunshine
 

Re: How to generate log file in TSII?

Postby before2012 » Fri Apr 19, 2013 8:10 am

sunshine wrote:Since the following line uses some internal variables, we have replaced the path to another and double-checked your code. It works without error.
Code: Select all
local __log_path = string.gsub(d-e-b-u-g.getinfo(1,"S").source,"^(.+\\)[^\\]+$", "%1");

So, it looks like the issue is related with this line.


you're right, it works now! thank you!!
before2012
 
Posts: 15
Joined: Fri Aug 26, 2011 12:57 am


Return to Discussions

Who is online

Users browsing this forum: No registered users and 10 guests