Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

why is get_type return userdata? #1563

Open
mumin1616 opened this issue Dec 14, 2023 · 0 comments
Open

why is get_type return userdata? #1563

mumin1616 opened this issue Dec 14, 2023 · 0 comments

Comments

@mumin1616
Copy link

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

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>();

How do I process userdata?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant