Same values but different results. Why and how?

Questions about MultiCharts and user contributed studies.
2haerim
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

Same values but different results. Why and how?

Postby 2haerim » 03 Oct 2008

Please open a chart window and add two symbols (1 tick each).
And apply the following code.

Code: Select all

input: F_ask1p(c of data2);


var: {F_ask1p(0),} F_ask1p_var(0);
var: cnt1(0), cnt1_var(0);

//============= Def of Data =======================
F_ask1p_var=c of data2;
//==================================================

// initialization of data

if date<>date[1] then begin
cnt1=0;
cnt1_var=0;
end;

if F_ask1p<>F_ask1p[1] then begin
cnt1=cnt1+1;
end;
if F_ask1p_var<>F_ask1p_var[1] then begin
cnt1_var=cnt1_var+1;
end;

if currentbar=1 then cleardebug;
if cnt1 < 30 or time_s>145000 then
print(BarNumber," ",
F_ask1p[1]," ",F_ask1p,F_ask1p[1]<>F_ask1p, " ", cnt1,
F_ask1p_var[1]," ",F_ask1p_var,F_ask1p_var[1]<>F_ask1p_var, " ", cnt1_var);
Some of the results are as follows:

1.00 189.15 189.15FALSE 0.00 0.00 189.15TRUE 1.00
2.00 189.15 189.15FALSE 0.00 189.15 189.15FALSE 1.00
2.00 189.15 189.15FALSE 0.00 189.15 189.15FALSE 1.00
3.00 189.15 189.15FALSE 0.00 189.15 189.15FALSE 1.00
3.00 189.15 189.15FALSE 0.00 189.15 189.15FALSE 1.00
4.00 189.15 189.15FALSE 0.00 189.15 189.15FALSE 1.00
4.00 189.15 189.10TRUE 1.00 189.15 189.10TRUE 2.00

5.00 189.15 189.10TRUE 1.00 189.10 189.10FALSE 1.00
5.00 189.10 189.10FALSE 1.00 189.10 189.10FALSE 1.00
6.00 189.10 189.10FALSE 1.00 189.10 189.10FALSE 1.00
6.00 189.10 189.10FALSE 1.00 189.10 189.10FALSE 1.00
7.00 189.10 189.10FALSE 1.00 189.10 189.10FALSE 1.00
...
18.00 189.10 189.10FALSE 1.00 189.10 189.10FALSE 1.00
19.00 189.10 189.10FALSE 1.00 189.10 189.10FALSE 1.00
19.00 189.10 189.10FALSE 1.00 189.10 189.10FALSE 1.00
20.00 189.10 189.10FALSE 1.00 189.10 189.10FALSE 1.00
20.00 189.10 189.05TRUE 2.00 189.10 189.05TRUE 2.00
21.00 189.10 189.05TRUE 2.00 189.05 189.05FALSE 1.00
21.00 189.05 189.05FALSE 2.00 189.05 189.05FALSE 1.00
22.00 189.05 189.05FALSE 2.00 189.05 189.05FALSE 1.00
...
36.00 189.05 189.05FALSE 2.00 189.05 189.05FALSE 1.00
37.00 189.05 189.05FALSE 2.00 189.05 189.05FALSE 1.00
37.00 189.05 189.05FALSE 2.00 189.05 189.05FALSE 1.00
38.00 189.05 189.05FALSE 2.00 189.05 189.05FALSE 1.00
38.00 189.05 189.00TRUE 3.00 189.05 189.00TRUE 2.00
39.00 189.05 189.00TRUE 3.00 189.00 189.00FALSE 1.00
39.00 189.00 189.00FALSE 3.00 189.00 189.00FALSE 1.00
40.00 189.00 189.00FALSE 3.00 189.00 189.00FALSE 1.00
40.00 189.00 189.00FALSE 3.00 189.00 189.00FALSE 1.00
41.00 189.00 189.00FALSE 3.00 189.00 189.00FALSE 1.00
41.00 189.00 188.95TRUE 4.00 189.00 188.95TRUE 2.00
42.00 189.00 188.95TRUE 4.00 188.95 188.95FALSE 1.00
42.00 188.95 188.95FALSE 4.00 188.95 188.95FALSE 1.00
43.00 188.95 188.95FALSE 4.00 188.95 188.95FALSE 1.00
...

[Questions]

[1] Why do I get two lines for each barnumber? I guess MC calculates the script for each barnumber for both data1 and data2. Is blue line for data1 and red line for data2? How can I tell which line is from which data series? I would like to understand when and how many times and in what order a script is calculated.

[2] And the above result is when the script is calcuated on subchart #1 basis. What would happen if I change it to be based on another subchart possibly having different resolution?

[3] If you compare blue line and red line, the values for F_ask1p and F_ask1p_var are always the same except the very first line. Here I have two things I don't understand. First, the blue lines have the same values for F_ask1p and F_ask1p_var. The red line have different values. And consequently cnt1 and cnt1_var does not increase on blue lines. However, on red lines F_ask1p and F_ask1p_var have different values resulting in cnt1 increases as expected. But in even the red lines does not increase cnt1_var at all. The only difference is that F_ask1p is declared as input and F_ask1p_var is declared as variable.
Please explain the mechanisms from which I got these different results.

There are so many factors in understanding how a script works when it is applied to a multi-sumbol chart: #of symbols, resolution, the based chart, use of " of dataN" phrase in the script, and so on. I wish I have a full documentation about all these complication in FULL detail with plenty examples comparing different combinations of the above mentioned factors.

Thanks.

Return to “MultiCharts”