Stumped...

Hey everyone, i am trying to pull a csv excel sheet from my site using a .lua script.  The file is at 

http://johnnymedal.com/1l.csv

and I replaced the http:load in my script below… and i cant see anything else this would need… heres the script…

function Init() indicator:name("1L"); indicator:description("1L"); indicator:requiredSource(core.Bar); indicator:type(core.View); indicator.parameters:addString("IDX", "1L", "", "1L"); indicator.parameters:addString("TF", "Time frame", "", "d"); indicator.parameters:addStringAlternative("TF", "Day", "", "d"); indicator.parameters:addStringAlternative("TF", "Week", "", "w"); indicator.parameters:addStringAlternative("TF", "Month", "", "m"); indicator.parameters:addDate("FROM", "Date from", "", -1000); indicator.parameters:addDate("TO", "Date to", "", 0); indicator.parameters:setFlag("TO", core.FLAG\_DATE); end local O, H, L, C, V -- initializes the instance of the indicator function Prepare(onlyName) local IDX = instance.parameters.IDX; assert(IDX ~= "", "1L"); local TF = instance.parameters.TF; local name = profile:id() .. "(" .. IDX .. "@1L, " .. TF .. ")"; instance:name(name); if onlyname then return ; end instance:initView(IDX, 2, 0.01, true, false); O = instance:addStream("O", core.Line, name .. ".O", "O", core.rgb(255, 0, 0), 0); H = instance:addStream("H", core.Line, name .. ".H", "H", core.rgb(255, 0, 0), 0); L = instance:addStream("L", core.Line, name .. ".L", "L", core.rgb(255, 0, 0), 0); C = instance:addStream("C", core.Line, name .. ".C", "C", core.rgb(255, 0, 0), 0); V = instance:addStream("V", core.Line, name .. ".V", "V", core.rgb(255, 0, 0), 0); instance:createCandleGroup(IDX, IDX, O, H, L, C, V, TF); core.host:execute("setTimer", 1, 1); StartLoading(IDX, TF, instance.parameters.FROM, instance.parameters.TO); end function Update(period) end local http, loading, loadError; function StartLoading(index, timeframe, \_from, \_to) local from = core.dateToTable(\_from); local to = core.dateToTable(\_to); local url; url = "/table.csv?s=" .. index .. "&a=" .. string.format("%02i", from.month - 1) .. "&b=" .. (from.day) .. "&c=" .. (from.year) .. "&d=" .. string.format("%02i", to.month - 1) .. "&e=" .. (to.day) .. "&f=" .. (to.year) .. "&g=" .. timeframe .. "&ignore=.csv"; if http == nil then http = core.makeHttpLoader(); end http:load("johnnymedal.com", 80, url, true); loading = true; loadError = false; core.host:execute("setStatus", "loading..."); end local pattern\_line = "([^,]\*),([^,]\*),([^,]\*),([^,]\*),([^,]\*),([^,]\*),[^,]\*%c+()"; local pattern\_date = "(%d%d%d%d)-(%d%d)-(%d%d)"; function AsyncOperationFinished(cookie, success, message) if cookie == 1 then if loading then if not(http:loading()) then loading = false; if http:successful() then local body = http:response(); local pos; local date, open, high, low, close, volume, t, period; local year, month, day; local periods = {}; local count = 0; while true do date, open, high, low, close, volume, pos = string.match(body, pattern\_line, pos); if date == nil then break; end year, month, day = string.match(date, pattern\_date); if year ~= nil then t = {}; t.month = tonumber(month); t.day = tonumber(day); t.year = tonumber(year); t.hour = 0; t.min = 0; t.sec = 0; period = {}; period.date = core.tableToDate(t); period.open = tonumber(open); period.high = tonumber(high); period.low = tonumber(low); period.close = tonumber(close); period.volume = tonumber(volume); count = count + 1; periods[count] = period; end end local lastdate = nil, date, s; for i = count, 1, -1 do date = periods[i].date; if lastdate == nil or lastdate \< date then instance:addViewBar(date); s = O:size() - 1; O[s] = periods[i].open; H[s] = periods[i].high; L[s] = periods[i].low; C[s] = periods[i].close; V[s] = periods[i].volume; lastdate = date; else core.host:trace(string.format("%i %s %s", i, core.formatDate(lastdate), core.formatDate(date))); end end errorLoad = false; core.host:execute("setStatus", ""); return core.ASYNC\_REDRAW; else errorLoad = true; core.host:execute("setStatus", "load failed"); end end end end return 0; end function ReleaseInstance() if loading then while (http:loading()) do end end core.host:execute("killTimer", 1); end

Hi,

Is your question specifically in reference to downloading the file, or some specific aspect of your code?

Cheers.

Hi,

Is your question specifically in reference to downloading the file, or some specific aspect of your code?

Cheers.