multi-data series - is it possible detect by symbol name?

Questions about MultiCharts and user contributed studies.
vking
Posts: 235
Joined: 21 May 2009
Has thanked: 51 times
Been thanked: 41 times

multi-data series - is it possible detect by symbol name?

Postby vking » 26 Jan 2012

Hello - I am trying to use multi-data series chart and wondering if this is possible to detect by symbol name?

For example:

let's say - I have the following symbols in the chart:
ES - data 1
NQ - data 2

The current mode of indicator build:
value1=close of data1;
value2=close of data2;

This would expect the data to be in the same sequence. Wondering if there is any intelligent way to detect the symbol and use it like below(pseudo code):

--------
- ESID=detect the data stream for ES
- NQID=detect the data stream id for NQ
value1=close of ESID;
value2=close of NQID;
----------

Main reason for this is the flexibility this gives in terms of inserting the data in any sequence.

PS: as I am planning to work with more than 5 instruments in single chart - wondering if there are any efficient ways to build one single indicator which uses all these instruments.

Appreciate any input on this.

Thanks.

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

Re: multi-data series - is it possible detect by symbol name

Postby TJ » 26 Jan 2012

Hello - I am trying to use multi-data series chart and wondering if this is possible to detect by symbol name?

For example:

let's say - I have the following symbols in the chart:
ES - data 1
NQ - data 2

The current mode of indicator build:
value1=close of data1;
value2=close of data2;

This would expect the data to be in the same sequence. Wondering if there is any intelligent way to detect the symbol and use it like below(pseudo code):

--------
- ESID=detect the data stream for ES
- NQID=detect the data stream id for NQ
value1=close of ESID;
value2=close of NQID;
----------

Main reason for this is the flexibility this gives in terms of inserting the data in any sequence.

PS: as I am planning to work with more than 5 instruments in single chart - wondering if there are any efficient ways to build one single indicator which uses all these instruments.

Appreciate any input on this.

Thanks.
look up

GetSymbolName


eg.

Code: Select all

var:
Close.ES(0),
Close.NQ(0),
d1.symbol(""),
d2.symbol("");

d1.symbol = GetSymbolName of data1;
d2.symbol = GetSymbolName of data2;

if d1.symbol = "ES" then
Close.ES = close of data1
else
if d1.symbol = "NQ" then
Close.NQ = close of data1;


p.s. Please do not use generic variable name like value1. It will cost you time and loss hair to debug at a later date.

vking
Posts: 235
Joined: 21 May 2009
Has thanked: 51 times
Been thanked: 41 times

Re: multi-data series - is it possible detect by symbol name

Postby vking » 26 Jan 2012

Thanks TJ. Appreciate it.

For the benefit of others - here is how I used it to save CPU cycles(just an example).

Thanks.

Code: Select all

Vars: ESID(0);
Vars: NQID(0);

Vars: ESDATA(0);
Vars: NQDATA(0);

Vars: d1.symbol("");
Vars: d2.symbol("");

Once begin
d1.symbol = GetSymbolName of data1;
d2.symbol = GetSymbolName of data2;

if d1.symbol = "ESH12" then begin
ESID=1;
NQID=2;
end else if d1.symbol = "NQH12" then begin
ESID=2;
NQID=1;
end;
end;

ESDATA=close of data(ESID);
NQDATA=close of data(NQID);

plot1(ESDATA/NQDATA);


Return to “MultiCharts”