Dosihris wrote:Hi Victor,
thank you very much for this sample. i will test it in the next hours. I have already seen that there is a lua c++ project, another c++ project to initialize lua and a .net project that calculates the real values. well, i haven't testet this sample yet, but do you know a way to communicate from lua to a c# project without c++ wrapper projects? Somebody wrote it should be possible with a com visible .net assembly. do you know anything about this way?
Nic
I'm not sure, whether it's possible to call C# method from Lua via COM. I'll try to google it when I have more "free" time.
Dosihris wrote:Hi Victor,
i have testet your example. I can compile it and it works. Can you help me again with some parameters? I want to transfer some parameter from the indicator, some numeric values to c#... i want to evaluate the numbers and then create buy or sell orders with the .net api...
Thanks for your help
Nic
If you need an example of how to pass a parameter into your C# methods try to modify my sample like this:
- Code: Select all
--drawLine-sample.lua
function Update(period)
...
local fromDate, fromLevel, toDate, toLevel = LuaDll:getLineCoordinates(source.close[period]);
...
end
- Code: Select all
//LuaDll.h
int getLineCoordinates(lua_State *L)
{
// first parameter starts with 2. 1 contains called table/"object" (like "this" in C#)
if (!lua_isnumber(L, 2))
return luaL_error(L, "The first parameter must be a number");
double level = lua_tonumber(L, 2);
...
double lineStartLevel = LineCoordinatesCalculator::GetLineStartLevel(level);//call of C# method with a parameter
double lineEndLevel = LineCoordinatesCalculator::GetLineEndLevel(level);//call of C# method with a parameter
...