Copies of function

Posted By: Zheka

Copies of function - 01/29/18 12:45

Hi, everybody,

Let's say, there is a portfolio of 20+ market-systems which use only 4 algo functions but with different parameters (assets,TF,etc).

I read/store all params in a array of structs- one field of which is a pointer to the algo function, - and switch to the relevant set in a loop of algos.

The problem is with static vars - which of course get changed with every call to the same function- even though it is a different component.

Is there an elegant way in Lite-C to achieve what I want without having to create multiple clones of same algo functions?
Posted By: Dalla

Re: Copies of function - 01/29/18 12:51

Maybe I misunderstand the question, but isn't this what AlgoVars are for?
http://zorro-project.com/manual/en/algovar.htm
Posted By: Zheka

Re: Copies of function - 01/29/18 14:34

That's not the problem.
If there is an algo function tradeTrend() and e.g. I build frames in it by "skipping" bars, then when the same tradeTrend()function is called in a different component (i.e. with different params),
then the static var "skipped" bars gets changed as well. And so messes up frame construction in the first "instance".
Posted By: jcl

Re: Copies of function - 01/30/18 16:31

I would give the same answer as Dalla. Use no static var for skipped bars, but an algovar. Then it's individual per algo.

Alternatively, you can use a static series for storing those variables.
Posted By: Zheka

Re: Copies of function - 01/31/18 11:42

Ok, will probably use both. Thank you.
© 2024 lite-C Forums