Data Nb as an input

Questions about MultiCharts and user contributed studies.
Mydesign
Posts: 33
Joined: 15 Feb 2017
Has thanked: 5 times
Been thanked: 6 times

Data Nb as an input

Hello,

I would like to have the Data Nb as an input in a signal.

This works fine if I simply use that:

Code: Select all

``` Inputs: DataNb(2) ; If BarStatus(DataNb) = 2 then begin // whatever calculation based directly on Data(DataNb) end; ```
But what if I need to specify the Data Nb for a variable declaration ?

Code: Select all

``` Inputs: DataNb(2) ; Vars: Price(0, Data(DataNb)) ; Price = Close Data(DataNb) ; If BarStatus(DataNb) = 2 then begin // whatever calculation based on the variable "Price" end; ```
This does not compile:
syntax error, unexpected 'identificator', expecting 'numeric constant'

Thanks for your help !

Anna MultiCharts
Posts: 449
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 111 times

Re: Data Nb as an input

Hello, Mydesign!

Please try this way:

Code: Select all

```Inputs: DataNb(2) ; Vars: Price(0) ; Price = Close Data(DataNb) ; If BarStatus(DataNb) = 2 then begin // whatever calculation based on the variable "Price" end; ```

Mydesign
Posts: 33
Joined: 15 Feb 2017
Has thanked: 5 times
Been thanked: 6 times

Re: Data Nb as an input

Thank you Anna,

I know this will work (compile) without assigning a Data Nb within the variable declaration, but I though this was the only way in certain situation to get things calculated correctly with multi-datas setups.

Said otherwise, what is the general purpose of this kind of syntax when using several datas ?:

Code: Select all

``` Vars: Var1(0, Data2) ; ```
vs

Code: Select all

``` Vars: Var1(0) ; ```

I have some code that does not behave the same wether I omit it or not, so I guess it has a mandatory purpose... no ?

Sorry if I stated the obvious, but this whole multi-Datas handling in EL is a bit confusing for me.

Thanks for your help.

TJ
Posts: 7210
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 991 times
Been thanked: 2052 times

Re: Data Nb as an input

Mydesign
Posts: 33
Joined: 15 Feb 2017
Has thanked: 5 times
Been thanked: 6 times

Re: Data Nb as an input

Thank you TJ,

That is actually my whole point: If one has to specify the data Nb in a variable declaration (as described in your link), how can we have this Data Nb as an input at the same time ?

Mydesign
Posts: 33
Joined: 15 Feb 2017
Has thanked: 5 times
Been thanked: 6 times

Re: Data Nb as an input

Can someone enlight me on that problem, please ?

So far I got contradicting infos:
Anna suggests to omit the Data Nb in the variable declaration.
TJ confirms that we have to specify the Data Nb in the variable declaration (as per post #5 of his link).

Mydesign
Posts: 33
Joined: 15 Feb 2017
Has thanked: 5 times
Been thanked: 6 times

Re: Data Nb as an input

Anyone ?

Anna MultiCharts
Posts: 449
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 111 times

Re: Data Nb as an input

Hello, Mydesign!

If you’re not planning to reference historical values of the variable then there no difference in how you declare it. You can do it this way:

Code: Select all

```Vars: Price(0) ; Price = Close Data(2) ; Plot1(Price); ```
or this way:

Code: Select all

```Vars: Price(0,2) ; Price = Close Data(2); Plot1(Price);```
The way you declare variables will only have influence if you’re going to reference its historical values. This code:

Code: Select all

```Vars: Price(0) ; Price = Close Data(2) ; Plot1(Price[1]); ```
will give different results as opposed to this one:

Code: Select all

``` Vars: Price(0,2) ; Price = Close Data(2) ; Plot1(Price[1]);```

Mydesign
Posts: 33
Joined: 15 Feb 2017
Has thanked: 5 times
Been thanked: 6 times

Re: Data Nb as an input

Thanks a lot Anna ! I finally understand the use of this declaration in case one needs to reference historical data This is not documented.

Then, back to my initial question: how do I make the Data Nb as an input in such case, when I need to reference historical values ?

Code: Select all

```Inputs: DataNb(2) ; Vars: Price(0, Data(DataNb)) ; Price = Close Data(DataNb) ; If BarStatus(DataNb) = 2 then begin // whatever calculation based on historical Price[x] end; ```

Anna MultiCharts
Posts: 449
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 111 times

Re: Data Nb as an input

Mydesign,

Variables cannot be declared dynamically like:

Code: Select all

`Vars: Price(0, Data(DataNb))`
You should use one of the following variants:

Code: Select all

`Vars: Price(0) \\ if you’re not planning to reference historical values`
or

Code: Select all

`Vars: Price(0,data2) \\ if you’re planning to reference historical values`

Mydesign
Posts: 33
Joined: 15 Feb 2017
Has thanked: 5 times
Been thanked: 6 times

Re: Data Nb as an input

Thank you Anna,

Ok, so what I want to do is simply not possible with MC.

Is the ability to optimize based on data resolution as a future feature still under review ? Any plan to implement that ?

Anna MultiCharts
Posts: 449
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 111 times

Re: Data Nb as an input

Mydesign,

Please specify the link to the PM request you’re referring to so I could check with the devs.

Mydesign
Posts: 33
Joined: 15 Feb 2017
Has thanked: 5 times
Been thanked: 6 times

Re: Data Nb as an input

Anna MultiCharts
Posts: 449
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 111 times

Re: Data Nb as an input

Mydesign,

This feature request is postponed and I’m afraid there’s no ETA when we can expect it.