[Not the two parameter array-access overload]
Given, in the KB:
where, and similarly for myStudy2
and
there seems to be a contradiction. ema() is one of the built-in studies, so it returns a series, so getSeries() would seem to be redundant.
But experimentation (with volume() rather than ema()) shows that getSeries() does make a difference.
In the EFS Custom folder there is a customVolume study, it does a
I have been using this with a five minute interval on a one minute chart. See how it retrospectively changes the volume for EACH of the one minute bars in the "current" five minute bar as the five minute bar is built.
The performance monitor shows that this routine is very inefficient, so I recoded it using some stored variables.
If you create a variable and initiate it with the series and then return the variable the display changes. Why should that be? Infact various odd things happen, with historic and live bars behaving differently
See the attached chart, it shows only bars drawn after chart was loaded, not historical bars
Queries are:
Why does returning a variable that has had a series assigned to it not work just like returning the series function directly?
What does getSeries() do to fix this?
What is a simple explanation of when a longer time frame series is returned, all of the bars on the chart in the longer time frame are updated (not just current bar chart)?
But if you apply getSeries() to the variable it works again.
So what is it about needing getSeries() if the series is stored in a variable?
Given, in the KB:
PHP Code:
//use getSeries() to ensure that the actual series is being returned, rather than the values
return new Array( getSeries( myStudy1 ), getSeries( myStudy2 ) );
PHP Code:
myStudy1 = ema( 20, inv(30) );
Any of the Built-in Study Functions or Series Functions can be used to create a Series Object.
xSeriesObj = SeriesFunction( [ parameters ] )
Where: xSeriesObj is a user-defined variable and SeriesFunction is one of the Built-in Study or Series functions.
The parameters specified would correspond to the parameters for the specific series function if applicable.
xSeriesObj = SeriesFunction( [ parameters ] )
Where: xSeriesObj is a user-defined variable and SeriesFunction is one of the Built-in Study or Series functions.
The parameters specified would correspond to the parameters for the specific series function if applicable.
But experimentation (with volume() rather than ema()) shows that getSeries() does make a difference.
In the EFS Custom folder there is a customVolume study, it does a
PHP Code:
return volume(sym(vSymbol));
The performance monitor shows that this routine is very inefficient, so I recoded it using some stored variables.
If you create a variable and initiate it with the series and then return the variable the display changes. Why should that be? Infact various odd things happen, with historic and live bars behaving differently
PHP Code:
var xVolume = null; // scope outside main()
...
// init once
mxVolume = volume(sym(vSymbol)); // where vSymbol is like "IBM,5"
...
// Each tick
var fVol = mxVolume .getValue(0);
...
// alternative returns
return volume(sym(vSymbol)); // 1. original version, see that in current bars the group of one minute bars
// in the current five minute bar all change together (ie not just the current one minute bar).
// How does that actually work, afterall, we are returnig data for the chart's current one minute bar?
return mxVolume; // 2. surely this returns the series just like the first return line. But it doesn't, instead see garbage data, why?
return getSeries(mxVolume); // 3. This displays just like the first return line. Why is getSeries() needed?
return fVol; // 4. now we see that for curernt (not historic) bars, each one minute bar in the same five mnute group is different,
//and grows, this at least makes sense, but you realise why the first return is so neat.
Queries are:
Why does returning a variable that has had a series assigned to it not work just like returning the series function directly?
What does getSeries() do to fix this?
What is a simple explanation of when a longer time frame series is returned, all of the bars on the chart in the longer time frame are updated (not just current bar chart)?
But if you apply getSeries() to the variable it works again.
So what is it about needing getSeries() if the series is stored in a variable?
Comment