Output series data to CSV - dynamic length?

Posted By: pounceyzorro

Output series data to CSV - dynamic length? - 10/09/21 13:38

Hi,

Another noobie question...

I have coded up some specific series that I'd like to export to a CSV file; would have thought it to be pretty easy,
however, am not sure I am seeing the right output length's for the calculated series; I tried NumBars; it came out 0,
then Lookback, which was 80, etc... Am looking for something like the pseudocode below; I will adapt it to write to a
file, etc. The real issue is this: what should mySeriesLength be set to? Do I have to use a different function other
than run() to accompish this? It appeared that any output printf's in run() executed BEFORE the data was loaded,
series were calculated, etc.

vars myseries1=series(<function of interest>);
vars myseries2=series(<function of interest>);
...
for(i=0; i < mySeriesLength; i++)
{
printf("%f %f", myseries1[i],myseries2[i]);
}

Please advise,
TIA for your help,
Vode Norwood
Posted By: Chiller

Re: Output series data to CSV - dynamic length? - 10/09/21 15:28

run is executed on every bar.
The first too times and the last time you can detect with the flags INITRUN, FIRSTRUN and EXITRUN.
e.g. if (!is(INITRUN)) will spare the initrun.
After the function run you still have an extra function thats called evaluate (and before main) these 2 are not repeated.
Posted By: Spirit

Re: Output series data to CSV - dynamic length? - 10/09/21 16:22

The length of a series is given in the series call, if none is given it's the lookback period.
Posted By: pounceyzorro

Re: Output series data to CSV - dynamic length? - 10/10/21 00:45

Quick question: so, on each invocation of run(), the series values in, say, series[0] should give the current value that was calculated, independent of how many are being stored via the lookback period default length? Am assuming that the series acts like a queue, with data shifted from [0] to [1]...up through [lookback length -1] and the new data being placed in [0].

TIA for any responses,
Vode
© 2024 lite-C Forums