Accessing time series in TMF

Posted By: StefanCGN

Accessing time series in TMF - 09/04/19 09:59

Hi all,

I am trying to develop a TMF, that wants to use filtered price data, but I am not able to access this data inside a TMF.
Does anybody have an example, where / how to declare the series variables, that it works?

Thanks in advance!
Posted By: felixfx

Re: Accessing time series in TMF - 10/23/19 19:54

hi, I am having the same issue, I am unable to pass a whole series into a TMF.
The half-way solution right now that I know of is to use Asset Variables for the TMF.
The problem with this hacky solution is that AssetVar only goes up to [7], which I'm sure in our case we need more than 7 potential
variables to pass to the TMF

#define VARIABLE AssetVar[0] // no semi-colon
#define VARIABLE1 AssetVar[1]

function run()
{
vars your_series = series(some_fuction);
VARIABLE = your_series[0];
VARIABLE1 = your_series[1];
}
Posted By: AndrewAMD

Re: Accessing time series in TMF - 10/23/19 20:16

If you really need the series in a TMF, generate the series in run(). Note that series returns a vars - this is actually a pointer to a var array (or a double array). Hold on to the pointer and use it to access the time series from any function. You should assume the pointer expires every time run() is invoked.
Posted By: felixfx

Re: Accessing time series in TMF - 10/24/19 22:26

Originally Posted by AndrewAMD
If you really need the series in a TMF, generate the series in run(). Note that series returns a vars - this is actually a pointer to a var array (or a double array). Hold on to the pointer and use it to access the time series from any function. You should assume the pointer expires every time run() is invoked.


could you please give an example of this?
Posted By: AndrewAMD

Re: Accessing time series in TMF - 10/24/19 22:43

Make a global vars. During run(), set the vars to a series() call. Then access the global vars anywhere.

Why not give it a try? laugh
Posted By: felixfx

Re: Accessing time series in TMF - 10/25/19 18:11

here is my interpretation:

vars Close; // unintialized vars GLOBAL

function run()
{
Close = series(priceClose()); // series that generate within run()
}

the way this would work is the series is running within run() but sends the series data over to a global vars.
But what is the outcome of " the pointer expires every time run() is invoked."?

Does it mean Close is only capable of accessing [0] since the pointer is expired each iteration of run() ?
Posted By: AndrewAMD

Re: Accessing time series in TMF - 10/25/19 18:30

Originally Posted by felixfx
Does it mean Close is only capable of accessing [0] since the pointer is expired each iteration of run() ?
No, you still have the whole series.

This is what I meant:

1) run () invoked
2) save to global vars
3) run() invocation is complete
4) access the vars from tick()
5) access the vars from TMF
6) access the vars from tick()
7) access the vars from TMF
8) run () invoked
9) Now your vars has expired, you need to set it to the global vars again
10) run() invocation is complete

If you try to dereference an invalid (or "expired") pointer, your script will exhibit undefined behavior. By that, I mean your vars expires. Don't use an expired vars.
© 2024 lite-C Forums