How to have a function to return two value

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

How to have a function to return two value

Postby arjfca » 05 Jan 2011

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 Test1
Input:
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

Postby Rommi » 05 Jan 2011

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.

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

Re: How to have a function to return two value

Postby TJ » 05 Jan 2011

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: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: How to have a function to return two value

Postby arjfca » 05 Jan 2011

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

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

Re: How to have a function to return two value

Postby TJ » 05 Jan 2011

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

Postby Rommi » 06 Jan 2011

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.


Return to “MultiCharts”