function AD()
local out = {}
for i = 1, #CLOSE, 1 do
hi=high[i];
lo=low[i];
cl=close[i];
sum=(cl-lo)-(hi-cl);
if hi==lo then
sum=0.0;
else
sum=(sum/(hi-lo))*VOLUME[i];
end
if i>1 then
sum=sum+out[i-1];
end
out[i]=sum;
end
return out
end
the following function return table:
function SMA(source, period)
if type(source) == type(1) then
if source == 0 then
source = CLOSE
elseif source == 1 then
source = OPEN
elseif source == 2 then
source = HIGH
elseif source == 3 then
source = LOW
elseif source == 4 then
source = MEDIAN
elseif source == 5 then
source = TYPICAL
elseif source == 6 then
source = WEIGHTED
end
end
local sum = SUM(source, period)
local out = {}
for j = 1, #sum, 1 do out[j] = sum[j] / period end
return out
end
why is first function return userdata? i want table, process is easy:
//c++
auto ret_val = lua["blabla"].get<std::vector>();
the following function return userdata:
function AD() local out = {} for i = 1, #CLOSE, 1 do
hi=high[i]; lo=low[i]; cl=close[i]; sum=(cl-lo)-(hi-cl); if hi==lo then sum=0.0; else sum=(sum/(hi-lo))*VOLUME[i]; end if i>1 then sum=sum+out[i-1]; end
end return out end
the following function return table:
function SMA(source, period) if type(source) == type(1) then if source == 0 then source = CLOSE elseif source == 1 then source = OPEN elseif source == 2 then source = HIGH elseif source == 3 then source = LOW elseif source == 4 then source = MEDIAN elseif source == 5 then source = TYPICAL elseif source == 6 then source = WEIGHTED end end local sum = SUM(source, period) local out = {} for j = 1, #sum, 1 do out[j] = sum[j] / period end return out end
why is first function return userdata? i want table, process is easy: //c++ auto ret_val = lua["blabla"].get<std::vector>();
How do I process userdata?