Problem in creating new function - a beginner question

Questions about MultiCharts and user contributed studies.
kitwckalex
Posts: 4
Joined: 09 Nov 2009

Problem in creating new function - a beginner question

Postby kitwckalex » 14 Nov 2009

I am creating a new function with the following codes.

Code: Select all

if CloseD[1] > HighD then
DayTrueHigh = CloseD[1]
else
DayTrueHigh = HighD;


But when compiled, it shows
"Invalid number of parameters. 1 parameter(s) expected
errLine 1, errColumn 3, errLineEnd 1, errColumnEnd 3"
How could I solve this? Thank you for your attention.

geektrader
Posts: 100
Joined: 17 Jul 2009
Location: Germany

Postby geektrader » 14 Nov 2009

var: DayTrueHigh(0);

if CloseD(1) > HighD(0) then
DayTrueHigh = CloseD(1)
else
DayTrueHigh = HighD(0);

kitwckalex
Posts: 4
Joined: 09 Nov 2009

Postby kitwckalex » 14 Nov 2009

var: DayTrueHigh(0);

if CloseD(1) > HighD(0) then
DayTrueHigh = CloseD(1)
else
DayTrueHigh = HighD(0);
Thanks geektrader.
But this compiled with error:

"syntax error, unexpected 'function return value', expecting 'identificator'
errLine 1, errColumn 5, errLineEnd 1, errColumnEnd 5"

User avatar
TJ
Posts: 7402
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2123 times

Postby TJ » 15 Nov 2009

what did you have as your function name?


the function name should be the same as your output name.

in this case, it should be DayTrueHigh

kitwckalex
Posts: 4
Joined: 09 Nov 2009

Postby kitwckalex » 15 Nov 2009

The function name is DayTrueHigh, same as the output name.

When creating this new function, I choose the return type as numeric and function storage as auto-detect. Does this make a difference?

User avatar
TJ
Posts: 7402
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2123 times

Postby TJ » 15 Nov 2009

var: DayTrueHigh(0);

if CloseD(1) > HighD(0) then
DayTrueHigh = CloseD(1)
else
DayTrueHigh = HighD(0);

you do not need this line:
var: DayTrueHigh(0);



The return type must be numeric
because you are not looking for a string or True/False return.

The function storage should be auto-detect.

kitwckalex
Posts: 4
Joined: 09 Nov 2009

Postby kitwckalex » 15 Nov 2009

Thanks a lot.

It complied sucessfully.

:D


Return to “MultiCharts”