2nd Data Series Problem

Questions about MultiCharts and user contributed studies.
User avatar
t-rader
Posts: 139
Joined: 02 Feb 2011
Location: Australia
Has thanked: 11 times
Been thanked: 27 times

2nd Data Series Problem

Postby t-rader » 08 Sep 2011

Hi All,

I’m trying to create a system that uses 2 time frames / data series.

The 1st data series (primary) is 1min.
The 2nd data series is 2min.

The code executes every minute as this is the primary data series (as you would expect) but the problem is the code is excuting every minute on the 2min data series which is causing duplicate values.

You can easily see this by creating a signal with the following code:

print(close data(2):0:5);

This will output duplicate close prices for the 2nd data series. Eg:

1.30785
1.30785
1.30820
1.30820
1.30745
1.30745

How do I get prevent or get rid of the duplicate values?

HarryHindsight
Posts: 14
Joined: 04 Sep 2010
Has thanked: 1 time
Been thanked: 4 times

Re: 2nd Data Series Problem

Postby HarryHindsight » 08 Sep 2011

Hi
I got rid of a lot of my data2 problems by using
if time of data1 = time of data2 then print(close of data2).

User avatar
t-rader
Posts: 139
Joined: 02 Feb 2011
Location: Australia
Has thanked: 11 times
Been thanked: 27 times

Re: 2nd Data Series Problem

Postby t-rader » 08 Sep 2011

Hi Harry,

Can you please elaborate a bit more? Maybe post a small example if possible?

I would think the time in both data series would be the same just the higher time frame the bar just hasn't actually closed yet?

Cheers,

champski
Posts: 54
Joined: 28 Jun 2011
Has thanked: 15 times
Been thanked: 1 time

Re: 2nd Data Series Problem

Postby champski » 08 Sep 2011

Guys,

(T-rader, I hope I'm not hijacking your thread but instead helping both of us with our similar issues).

I'm having similar problems and am trying to work out how I can do a moving average of the last 20 bars of data2 on a signal where data1 is the primary.
- data1 is 1 minute
- data2 is 2 minute
My issue with this (I think) is that the length variable is referencing data1 bars and not data2 bars. Therefore, giving me incorrect results.

A snippet of my code looks like this;

Code: Select all

[Intrabarordergeneration=true]

var: intrabarpersist RollingAverage(0),
length(20);

RollingAverage = summation(close, length)/20
print(rollingaverage:0:5)


Thanks in advance!!
Champski

HarryHindsight
Posts: 14
Joined: 04 Sep 2010
Has thanked: 1 time
Been thanked: 4 times

Re: 2nd Data Series Problem

Postby HarryHindsight » 08 Sep 2011

Have a good look at easylanguage essentials (its on the site somewhere)they cover most of it. In my case i found the function values were correct when the bar of data2 (10min) closed at 00:10 but at 00:12 the function values were wrong so i assigned the values only when data2 closed. Barstatus = 2 didn't seem to work for me so i used time.

Code: Select all

if time of data1 = time of data2 then
myVar = functionValue
end;


Majority of functions will return the correct value no matter what, just depends what you are using.

The time of data2 is the time of the last bar that closed not the unfinished current bar.This should only run every 2nd minute as you wanted ?

Code: Select all

if time of data1 = time of data2 then
 print(close of data2)
{your code}
end;

I'm learning so am happy to be corrected
These users thanked the author HarryHindsight for the post (total 2):
TJfurytrader

HarryHindsight
Posts: 14
Joined: 04 Sep 2010
Has thanked: 1 time
Been thanked: 4 times

Re: 2nd Data Series Problem

Postby HarryHindsight » 08 Sep 2011

https://www.multicharts.com/multicharts/ ... mentation/

The easylanguage manuals are here , a pack of paracetamol is in the inside jacket :)


Return to “MultiCharts”