data1, data2

Questions about MultiCharts and user contributed studies.
User avatar
konstantin
Posts: 69
Joined: 24 Dec 2007
Location: Europe
Has thanked: 2 times
Been thanked: 1 time

data1, data2

Postby konstantin » 26 Feb 2008

Does anyone have a sample of a simple signal based on two datastreams data1 and data2?

For me data1/data2 does not work and I cant find out why!

Is it possible that if a function is not coded properly then the signals based on this function do not work with data1 and data2 ??

Is it possible to reference past values in data2 ?
e.g. "average(price, length)[1] of data2"

itai007
Posts: 69
Joined: 14 Jun 2007

Re: data1, data2

Postby itai007 » 26 Feb 2008

Does anyone have a sample of a simple signal based on two datastreams data1 and data2?

For me data1/data2 does not work and I cant find out why!

Is it possible that if a function is not coded properly then the signals based on this function do not work with data1 and data2 ??

Is it possible to reference past values in data2 ?
e.g. "average(price, length)[1] of data2"

when refering to dataX ....

use:

close of data2
high of data3

highest(H,4) of data6

highD(0) of data 17

good luck

User avatar
konstantin
Posts: 69
Joined: 24 Dec 2007
Location: Europe
Has thanked: 2 times
Been thanked: 1 time

Re: data1, data2

Postby konstantin » 26 Feb 2008


when refering to dataX ....

use:

close of data2
high of data3

highest(H,4) of data6

highD(0) of data 17

good luck
Thank you.
This is what I use, but it does not work. The same code works if I use only one data, but when I use data1 and data2 the code does not work.

Is it possible to reference past values in data2 ?
e.g. "average(price, length)[1] of data2"

Can all functions be used for for data1, data2 ?

itai007
Posts: 69
Joined: 14 Jun 2007

data1 and data2

Postby itai007 » 26 Feb 2008

I have no problems using those terms ... here are 2 examples I use.

Code: Select all

var:
counter(0);

if time = SessionFirstBarTime(0,1) then counter = 0;

condition1 = close of data1 > high[1] of data2;
condition2 = close of data2 < Low[1] of data1;

if condition1 then counter = counter+1 else if condition2 then counter = counter-1;

plot1(counter);
plot2(0);

Code: Select all

inputs:
up(70),
dn(60);

plot1(c of data1 - c of data2);
plot2(up);
plot3(dn);

User avatar
konstantin
Posts: 69
Joined: 24 Dec 2007
Location: Europe
Has thanked: 2 times
Been thanked: 1 time

Postby konstantin » 26 Feb 2008

Thanks, I will try these codes.

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

Postby TJ » 26 Feb 2008

to make your program easy to read, it is better to assign a variable first.

e.g.


var: close1(0), close2(0);

close1 = close data1;
close2 = close data2;


then you can use close1 and close2 without having to worry about assigning data1 and data2 again.

User avatar
konstantin
Posts: 69
Joined: 24 Dec 2007
Location: Europe
Has thanked: 2 times
Been thanked: 1 time

Postby konstantin » 27 Feb 2008

Could someone test this simple test-code on 2 Datastreams?
Maybe I make a very stupid mistake in the code.
Use any Long exit signal:


inputs: price(close), length(20), rsilength(14);

variables: MAData2(0), Trend(0), EntryData1(0), RSIEntry(0);

MAData2 = average(price, length) of data2;
EntryData1 = rsi(price, rsilength) of data1;

{Trend}
If currentbar of data2 > 0 then begin
if MAData2 > MAData2[1] then Trend = 1;
if MAData2 <= MAData2[1] then Trend = 0;
end;

{Entry}
If currentbar of data1 > 0 then begin
if EntryData1 > EntryData1[1] and EntryData1[1] <= EntryData1[2] then RSIEntry = 1
else
RSIEntry = 0;
end;



if Marketposition = 0 then begin
if Trend = 1 and RSIEntry = 1 then
buy ( "Buy" ) next bar at Market ;
end;

dupl
Posts: 158
Joined: 04 Jul 2007

Postby dupl » 27 Feb 2008

I use this:

Code: Select all

inputs: DataSeries1( Close of data1 ), DataSeries2( Close of data2 ) ;
inputs: DataSeries3( Close of data3 ), DataSeries4( Close of data4 ) ;

Plot1( DataSeries1 - DataSeries4, "SprdDiff1", red );
...with 2 or more Datastreams.

fs

Postby fs » 27 Feb 2008

Could someone test this simple test-code on 2 Datastreams?
Maybe I make a very stupid mistake in the code.
Use any Long exit signal:


inputs: price(close), length(20), rsilength(14);

variables: MAData2(0), Trend(0), EntryData1(0), RSIEntry(0);

MAData2 = average(price, length) of data2;
EntryData1 = rsi(price, rsilength) of data1;

{Trend}
If currentbar of data2 > 0 then begin
if MAData2 > MAData2[1] then Trend = 1;
if MAData2 <= MAData2[1] then Trend = 0;
end;

{Entry}
If currentbar of data1 > 0 then begin
if EntryData1 > EntryData1[1] and EntryData1[1] <= EntryData1[2] then RSIEntry = 1
else
RSIEntry = 0;
end;



if Marketposition = 0 then begin
if Trend = 1 and RSIEntry = 1 then
buy ( "Buy" ) next bar at Market ;
end;
Your problem is with your input variable "price(close)". The way you define it, means your input value is the close of data1, meaning the close of data1 is always used everywhere you reference the price input variable.

For example, looking at the statement:

MAData2 = average(price, length) of data2;

and replacing it with the real value of price, translates to:

MAData2 = average(close of data1, length) of data2;

which doesn't make sense and the "of data2" part is ignored.

- Fanus

User avatar
konstantin
Posts: 69
Joined: 24 Dec 2007
Location: Europe
Has thanked: 2 times
Been thanked: 1 time

Postby konstantin » 28 Feb 2008

Of course, no I understand.
Thank you!


Return to “MultiCharts”