How to have a function to return two value

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1262
Joined: 23 Nov 2010
Has thanked: 716 times
Been thanked: 221 times

How to have a function to return two value

Something that I dont understand

How could I get a function to return two value. In the exemple, how do I return the value of Out1, Out2 to the caller

Code: Select all

`Test1(Val1, Val2);_________________________________________Function Test1Input:Val1 ( Numeric),Val2 (Numeric);Variables:Out1 (0),Out2 (0);Out1 = Val1 * val2;Out2 = Val1 + Val2;`

Rommi
Posts: 9
Joined: 15 Sep 2010

Re: How to have a function to return two value

Try this

Code: Select all

`inputs: Val1(numericseries),Val2(numericseries),   Out1(NumericRef),Out2(NumericRef);Test1=1;   Out1= Val1*Val2;Out2= Val1+Val2;`

For calling Out1 and Out2 in
indicator or system of other function

Code: Select all

`inputs: Val1(...),Val2(...);Vars: MyOut1(0),MyOut2(0);Value1 = Test1( Val1,Val2, MyOut1,MyOut2) ;`
Last edited by Rommi on 05 Jan 2011, edited 1 time in total.

TJ
Posts: 6519
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: How to have a function to return two value

arjfca wrote:Something that I dont understand

How could I get a function to return two value. In the exemple, how do I return the value of Out1, Out2 to the caller

go look at the stochastic code for example.

arjfca
Posts: 1262
Joined: 23 Nov 2010
Has thanked: 716 times
Been thanked: 221 times

Re: How to have a function to return two value

Thank you Rommi , TJ

Rommi, I succedded with your suggestion. I missed the dummy value provided by Value1.

I will work arround this solution

To both of you, My best wish for the New Year, Happy trading time

Martin

TJ
Posts: 6519
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: How to have a function to return two value

arjfca wrote:Thank you Rommi , TJ

Rommi, I succedded with your suggestion. I missed the dummy value provided by Value1.

I will work arround this solution

To both of you, My best wish for the New Year, Happy trading time

Martin

Thank you and you are welcome.
Best wishes to you too.

Rommi
Posts: 9
Joined: 15 Sep 2010

Re: How to have a function to return two value

arjfca wrote:Thank you Rommi , TJ

Rommi, I succedded with your suggestion. I missed the dummy value provided by Value1.

I will work arround this solution

To both of you, My best wish for the New Year, Happy trading time

Martin

You are welcom.
Best wishes to You too.