[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Another DLL question



PureBytes Links

Trading Reference Links


Thanks to the many who responded to my "Another DLL question" message
yesterday.  The answers have taught me a lot about how DLL's are allocated
and de-allocated by WIN, and by EL.

Last night, I did get the zero lag MA to plot but the procedure of clicking
between Windows, changing an INPUT on the fly, etc. was a pain. I know how
to simplify that now and within the next few days will implement the
changes.

Summary from responses to my questions were:

> 1)  Is the DLL and its GLOBAL variables being de-allocated and then >
re-allocated again on each pass of the same EL program?

Many say yes and the way around this is to have another inactive study
first call the same DLL.  As long as one process that calls a DLL is still
open, the DLL won't de-allocate.  It is purged only when all processes that
were linked to the DLL terminate.

>2)  When EL re-runs after changing an INPUT or turning STATUS OFF then ON,
>does EL re-initialize all VARS: (like set VAR1(5), to 5), and does EL
re-run >the DefineDLLFunc: and does that make a new DLL connection?

Consensus is YES.  All EL variables are overwritten and the entire EL
program starts from scratch.

>3)  Is there any EL variable that I can write to on one pass but will hold
>that value for additional passes of the same program?  What does EL do
during >an optimization?  It can't re-initialize everything between
optimization >passes, or can it?

Consensus was that no variable is safe.  All are re-initialized.  It's only
the inputs that are controlled during an optimization.

>If DefineDLLFunc: running more than once is re-allocating the DLL and its
>memory, than if there is a protected EL memory location, I could use it as
a >switch to conditionally run DefineDLLFunc: only on the first pass.  Any
>solution to this problem?

NO from the above answers.

I will change my DLL so that an INPUT state will make it only load price
data to an array from CurrentBar=1 through LastBarOnChart.  That action
will be done in an otherwise inactive workspace where there is no other
action.  In an active workspace, A second INPUT state will make the DLL
calculate forward and backward EMA's and the composite zero lag average (in
arrays) when CurrentBar = 1, using the price array loaded in the inactive
workspace.  Therefore EL will have the zero lag average to plot as it moves
forward bar by bar, and it will not erase the price array, so it can modify
the average INPUT parameters during an optimization. The DLL will
de-allocate only when both inactive and active work spaces are closed.

Only one person, Chris Baker, stated that a DLL does not de-allocate and
then re-allocate when EL starts another pass (like when changing an INPUT).

>>1)  Is the DLL and its GLOBAL variables being de-allocated and then
>>re-allocated again on each pass of the same EL program?

>That wasn't the case in VC++ 1.52

>In TS 4 the DLL link is done when the DLL is first called.  My >experience
was it won't be done again for the same DLL until TS 4 >Charting is shut
down and re-started.   Start the Omega debug program in >the Prog directory
before you run your ELA to see the dynamic linking to >the DLL.

Thanks, I will check that debug program.