How do you write a text file in Lua??

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

How do you write a text file in Lua??

Postby Trickie » Thu Aug 08, 2019 2:19 pm

After reading up on various online resources on how to write a text file from a TS2 indicator, I came up with the following to test things out ...
Code: Select all
local file = io.open("C:\Program Files (x86)\Candleworks\FXTS2\indicators\Custom\data.txt", "a+")
file:write("Hello World")
file:close()

However, it doesn't work at all! No errors, just no output. Any ideas what I'm doing wrong??

An alternative way to get round the problem - when I view a chart as a table, all the columns created by the indicator are integers - any idea how to display them to 2 decimal places like the OHLC data? On the chart itself the indicator values DO have 2 DP, so it's not that they don't exist. It would be useful to see those DPs in the table.

Thanks

Trickie
Trickie
 
Posts: 8
Joined: Tue Jul 30, 2019 5:05 am

Re: How do you write a text file in Lua??

Postby Apprentice » Mon Aug 12, 2019 6:50 am

local file = io.open("C:\Program Files
(x86)\Candleworks\FXTS2\indicators\Custom\data.txt", "a+")
This is an invalid path. Every \ shoudl be a double \ =>
local file = io.open("C:\\Program Files
(x86)\\Candleworks\\FXTS2\\indicators\\Custom\\data.txt", "a+")

Considering the second question... I need the code of this indicator
to figure out what is wrong
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 13 guests