Wrapping my head around series

Posted By: alun

Wrapping my head around series - 08/31/22 15:09

Zorro has this poweful concept of series:

Code
vars Closes = series(priceC());


Just decomposing it in plain C:

Code
double* Closes = series(priceC());


`priceC()` returns `double` and series just delegates to some other function `series0` which I can't find in sources.

Code
inline vars series(var val=0,int size=0) { return series0(val,size); }


I'd like to understand what C black magic transforms the double val parameter into a series of values with the respect to actual function passed into `series` argument?

This could help to build a better intuition around that call.

Would appreciate if someone could explain it.

Thanks,
Alex


Posted By: AndrewAMD

Re: Wrapping my head around series - 08/31/22 15:25

run() is called many times, and series() can only be called inside run(). series() counts the number of times it was invoked, corresponding to a particular timeseries.

Read about run() and series() here:
https://zorro-project.com/manual/en/run.htm
https://zorro-project.com/manual/en/series.htm
Posted By: alun

Re: Wrapping my head around series - 09/01/22 09:28

Hi Andrew, thanks for the answer.

I think I understand now, so it just has some counter (the number of a time series) which is reset to 0 before each run.

Then run called for each bar including LoopBack.

And the series number is incremented each time series called again.

Since the order of calls to series(...) remains the same - it can feed a simple double value to a relevant time series array.

And finally return what it has collected so far for this time series.

That's smart!

Thanks for the clues again!
© 2024 lite-C Forums