Can a function return a constant value without the history?

Questions about MultiCharts and user contributed studies.
hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Can a function return a constant value without the history?

Postby hughesfleming » 12 Sep 2015

I am calling a function that returns a period length and that period length has a history that varies and this works fine for adaptive indicators.

What I am trying to do is setup some bandpass filters which just receive the period length from the function without the history and then update on every new bar. I can't seem to figure out how to do this?

Any help would be greatly appreciated,

Alex

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Can a function return a constant value without the histo

Postby TJ » 12 Sep 2015

I am calling a function that returns a period length and that period length has a history that varies and this works fine for adaptive indicators.

What I am trying to do is setup some bandpass filters which just receive the period length from the function without the history and then update on every new bar. I can't seem to figure out how to do this?

Any help would be greatly appreciated,

Alex
Not sure what you mean by "period length has a history".

The function can return whatever you want it to return.


Take a look at the Stochastic function; it is THE SAMPLE script for intermediate level function coding.

hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: Can a function return a constant value without the histo

Postby hughesfleming » 12 Sep 2015

Thanks TJ,

What I mean is that the function will return a series of values which when used as an input to the bandpass filter will distort the filter which looks like a sine wave. I am interested in using just the value of the function at the current bar.

The function now may return a series of values eg. 21, 20,19,22. I am trying to get 21,21,21,21 and then to recalculate the whole indicator on the next bar which may have a value of 22 this time.

Sorry if my explanation was not very clear the first time.

regards,

Alex


Return to “MultiCharts”