Function result as function parameter

Questions about MultiCharts .NET and user contributed studies.
Fede
Posts: 3
Joined: 02 May 2011
Has thanked: 1 time

Function result as function parameter

Postby Fede » 27 Jan 2016

Hello,
I would like to use a ISeries that is the result of a function f that take as parameter the result of a function f'.
I mean instead of using the Instrument Prices plotted in the chart, I would like to use the result
of a FunctionSeries.

By example lets image (without details):

Code: Select all

f: FunctionSeries<System.Double> {
public ISeries<Double> Price { get; set; }

protected override System.Double CalcBar()
{

return Price[0]*2;

}
If I plot the result of my function from an Indicator and set the Price as the Bars.Close of the instrument I will have the Close * 2 plotted on the chart.
To have the Close * 4, I would call f(f'(Bars.Close)) in a way the first call apply f on the Bars.Close and the second apply f() to the result of f'.

To resume I want to pass the result of a function as ISeries use to calculate another function.

How could I do that?

Thanks a lot

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Function result as function parameter

Postby Henry MultiСharts » 27 Jan 2016

Hello Fede,

You need to create a series variable and assign your initial function's value to it. Then specify this variable as a parameter of your second function.

Fede
Posts: 3
Joined: 02 May 2011
Has thanked: 1 time

Re: Function result as function parameter

Postby Fede » 27 Jan 2016

I'm not sure to understand what you mean. Do you have an example ?
I take only two function as exemple like f and f', but I would like to call N time the function.
Something like : f1(f2(f3(...fn()))). Where N not known at the function definition.
Also f1,f2,fi.. can be the same function.
I mean a recursive call of the function with each time the result of the previous function.

It's something I was able to do withPowerLanguage. Calling a function giving a timeseries as parameter that is the result of another function.

Thanks

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Function result as function parameter

Postby Henry MultiСharts » 28 Jan 2016

Please refer to the attached sample file with the code.
Attachments
Test_RecursionCall.pln
(1.62 KiB) Downloaded 571 times


Return to “MultiCharts .NET”