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

Postby Mydesign » 03 Aug 2018

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 !

User avatar
Anna MultiCharts
Posts: 404
Joined: 14 Jul 2017
Has thanked: 28 times
Been thanked: 101 times

Re: Data Nb as an input

Postby Anna MultiCharts » 03 Aug 2018

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

Postby Mydesign » 03 Aug 2018

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.

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

Re: Data Nb as an input

Postby TJ » 03 Aug 2018


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

Re: Data Nb as an input

Postby Mydesign » 05 Aug 2018

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

Postby Mydesign » 08 Aug 2018

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

Postby Mydesign » 11 Aug 2018

Anyone ?

User avatar
Anna MultiCharts
Posts: 404
Joined: 14 Jul 2017
Has thanked: 28 times
Been thanked: 101 times

Re: Data Nb as an input

Postby Anna MultiCharts » 14 Aug 2018

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]);
These users thanked the author Anna MultiCharts for the post:
Mydesign

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

Re: Data Nb as an input

Postby Mydesign » 15 Aug 2018

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;

User avatar
Anna MultiCharts
Posts: 404
Joined: 14 Jul 2017
Has thanked: 28 times
Been thanked: 101 times

Re: Data Nb as an input

Postby Anna MultiCharts » 16 Aug 2018

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

Postby Mydesign » 17 Aug 2018

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 ?

User avatar
Anna MultiCharts
Posts: 404
Joined: 14 Jul 2017
Has thanked: 28 times
Been thanked: 101 times

Re: Data Nb as an input

Postby Anna MultiCharts » 17 Aug 2018

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

Postby Mydesign » 17 Aug 2018


User avatar
Anna MultiCharts
Posts: 404
Joined: 14 Jul 2017
Has thanked: 28 times
Been thanked: 101 times

Re: Data Nb as an input

Postby Anna MultiCharts » 30 Aug 2018

Mydesign,

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


Return to “MultiCharts”