What is indicore3_ffi

Moderator: admin

What is indicore3_ffi

Postby robocod » Wed Jan 13, 2016 7:42 am

What is "indicore3_ffi"?

I see several functions seem to have versions using indicore3_ffi. For example (from the SDK help file)...

boolean core.crossesOver (stream1, stream2, period1, period2?)
and
bool indicore3_ffi.core_crossesOver (void *stream1, void *stream2, int period1, int period2)

Please explain the purpose / benefit of using one over the other.
User avatar
robocod
FXCodeBase: Graduate
 
Posts: 298
Joined: Thu May 10, 2012 4:25 pm

Re: What is indicore3_ffi

Postby Alexey.Pechurin » Thu Jan 14, 2016 4:37 am

Hello robocod,

FFI is a way to increase performance in Lua JIT mode (and only in the mode). See http://luajit.org/ext_ffi.html for general information.

It's not intended for general indicators/strategies developers and must be used only when there are known performance bottlenecks in Lua code. It must be used with care: it you pass incorrect parameter to Indicore method - a general Lua indicator will be stopped, but in FFI mode entire application may crash. Also incorrect usage of FFI functions may even decrease overall performance. In the next TS release we'll introduce permissions and FFI permission will be disabled by default for custom indicators.

FFI functions were intended for standard indicators primarily but this API was opened for 3rd party developers too. But one more time - it must be used only when it's necessary and with care.

If you are interested in it we can provide some advices.
Alexey.Pechurin
 
Posts: 98
Joined: Sun Jul 22, 2012 11:26 pm

Re: What is indicore3_ffi

Postby lancelune » Mon Jan 25, 2016 1:29 pm

I have open ich.lua (standard indicator) and i see the code with 2 Update function.

there is no line with local ffi = require("ffi") to use ffi.
what is used ? What does it work?
It is not necessary to be a knight to have dreams. But it is necessary to be it to conquer them!
User avatar
lancelune
 
Posts: 24
Joined: Thu Aug 27, 2015 3:57 am

Re: What is indicore3_ffi

Postby Alexey.Pechurin » Tue Jan 26, 2016 9:13 am

Hello lancelune,

Global ffi variable is defined internally by Indicore when it's possible to use FFI (actually when LuaJIT mode is used). So we often use the pattern:

Code: Select all
if ffi then

-- FFI mode update
function Update(period, mode)
...
end

else

-- General mode
function Update(period, mode)
...
end

end
Alexey.Pechurin
 
Posts: 98
Joined: Sun Jul 22, 2012 11:26 pm

Re: What is indicore3_ffi

Postby MarkJoy » Sat Oct 01, 2016 8:01 am

Hello Alexey.Pechurin,

Is there a way to force a custom indicator always runs in ffi mode?

I have some MT4 indicators, I would like to convert them without the need of actually converting everything. I think it will help to reduce the efforts.

Thanks.
MarkJoy
 
Posts: 26
Joined: Sat Oct 01, 2016 7:53 am

Re: What is indicore3_ffi

Postby MarkJoy » Mon Oct 03, 2016 11:36 am

I got to know how to use the ffi lib. Just config the VM JIT and allow the ffi.
MarkJoy
 
Posts: 26
Joined: Sat Oct 01, 2016 7:53 am

Re: What is indicore3_ffi

Postby Apprentice » Tue Oct 04, 2016 2:33 am

Unfortunately, you will not be able to use MQ4 code without conversion.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 7 guests