A list of number in variable: Wath type of variable?  [SOLVED]

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1282
Joined: 23 Nov 2010
Has thanked: 724 times
Been thanked: 222 times

A list of number in variable: Wath type of variable?

Postby arjfca » 20 Oct 2012

Hello

In a function, I want to create a list of numbers separated by a comma like

Alist=(1.2345,1.2356,1.2367,1.2389) What kind of variable should I declare. It can't be a number since a comma will separate the list.

I could declare the list as a string, then use a Str2Num, but if there is another way, i would use it

I want to use these number ( alist) in a maxlist(alist).

Is it possible to not define my variable list as a string?

Martin

User avatar
TJ
Posts: 7153
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 988 times
Been thanked: 2041 times

Re: A list of number in variable: Wath type of variable?

Postby TJ » 20 Oct 2012

arjfca wrote:Hello

In a function, I want to create a list of numbers separated by a comma like

Alist=(1.2345,1.2356,1.2367,1.2389) What kind of variable should I declare. It can't be a number since a comma will separate the list.

I could declare the list as a string, then use a Str2Num, but if there is another way, i would use it

I want to use these number ( alist) in a maxlist(alist).

Is it possible to not define my variable list as a string?

Martin


How you go about making this function depends on
what, where, and how you want to use the end result.

arjfca
Posts: 1282
Joined: 23 Nov 2010
Has thanked: 724 times
Been thanked: 222 times

Re: A list of number in variable: Wath type of variable?

Postby arjfca » 21 Oct 2012

TJ wrote:
arjfca wrote:Hello

In a function, I want to create a list of numbers separated by a comma like

Alist=(1.2345,1.2356,1.2367,1.2389) What kind of variable should I declare. It can't be a number since a comma will separate the list.

I could declare the list as a string, then use a Str2Num, but if there is another way, i would use it

I want to use these number ( alist) in a maxlist(alist).

Is it possible to not define my variable list as a string?

Martin


How you go about making this function depends on
what, where, and how you want to use the end result.


Hello TJ

The end result to be use in a MaxList function

MaxList(Value1,Value2,Value3... etc). The Number of iteration of Value(x) to be defined by an input value

So my variable as to be a list like alist=(1.2345,1.2356,1.2378)

Hope I'm clearer

Martin

User avatar
TJ
Posts: 7153
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 988 times
Been thanked: 2041 times

Re: A list of number in variable: Wath type of variable?

Postby TJ » 21 Oct 2012

arjfca wrote:Hello TJ

The end result to be use in a MaxList function

MaxList(Value1,Value2,Value3... etc). The Number of iteration of Value(x) to be defined by an input value

So my variable as to be a list like alist=(1.2345,1.2356,1.2378)

Hope I'm clearer

Martin


You don't need to create a function, you can simply add the variables directly to Maxlist.

arjfca
Posts: 1282
Joined: 23 Nov 2010
Has thanked: 724 times
Been thanked: 222 times

Re: A list of number in variable: Wath type of variable?

Postby arjfca » 21 Oct 2012

Good day TJ

The number of variable is to be defined by a an Input value

What I want to do.

I'm defining and show a bar that as depict an increase of volatility. To do so, I compare body's of previous bar. If the actual body is greater than (x) numbers of body bar before, then this bar
is a Wide Range Bady ( WRB)

Actually, my code is hard coded to look for the previous 3 bars like
If Body[1] is > Maxlist(Body[2],Body[3],Body[4]) then WRB = True

Now, I want to modify my code so it would be flexible in the numbers of bar ago I want to check. To do so, my idea was to build my data string instead of hard coded one like I actually do.

Martin

User avatar
TJ
Posts: 7153
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 988 times
Been thanked: 2041 times

Re: A list of number in variable: Wath type of variable?  [SOLVED]

Postby TJ » 21 Oct 2012

arjfca wrote:Good day TJ

The number of variable is to be defined by a an Input value

What I want to do.

I'm defining and show a bar that as depict an increase of volatility. To do so, I compare body's of previous bar. If the actual body is greater than (x) numbers of body bar before, then this bar
is a Wide Range Bady ( WRB)

Actually, my code is hard coded to look for the previous 3 bars like
If Body[1] is > Maxlist(Body[2],Body[3],Body[4]) then WRB = True

Now, I want to modify my code so it would be flexible in the numbers of bar ago I want to check. To do so, my idea was to build my data string instead of hard coded one like I actually do.

Martin


You can do this:

Code: Select all

input:
Look.back(3);

Var:
WRB(false);

WRB = Body[1] > Highest( Body, Look.back )[2];


Return to “MultiCharts”