synchronization issues using GVsetXX/GVgetXX pair w/ IOG on

Questions about MultiCharts and user contributed studies.
kernel
Posts: 91
Joined: 19 Feb 2013
Has thanked: 21 times
Been thanked: 4 times

synchronization issues using GVsetXX/GVgetXX pair w/ IOG on

Postby kernel » 10 Jan 2016

Hi,

I found some synchronization issues when using GVSetNamedInt/GVGetNamedInt pair from time to time.

For example, I have several 5m charts (on 5 different windows) with different instruments. On each bar close (my script is IOG=true though), each chart broadcasts its C[1]-O[1] value, while collecting the same piece of info broadcast by others....sounds simple right? However, I found there are always some charts broadcasting info of one bar ahead, that is, C[2]-O[1], instead of C[1]-O[1]. Wonder if you folks have ever run into similar "off-by-one" issues and how you fixed them? Thanks.

-Kernel

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

Re: synchronization issues using GVsetXX/GVgetXX pair w/ IOG

Postby TJ » 10 Jan 2016

Hi,

I found some synchronization issues when using GVSetNamedInt/GVGetNamedInt pair from time to time.

For example, I have several 5m charts (on 5 different windows) with different instruments. On each bar close (my script is IOG=true though), each chart broadcasts its C[1]-O[1] value, while collecting the same piece of info broadcast by others....sounds simple right? However, I found there are always some charts broadcasting info of one bar ahead, that is, C[2]-O[1], instead of C[1]-O[1]. Wonder if you folks have ever run into similar "off-by-one" issues and how you fixed them? Thanks.

-Kernel
For code debugging questions,
please post your code.

kernel
Posts: 91
Joined: 19 Feb 2013
Has thanked: 21 times
Been thanked: 4 times

Re: synchronization issues using GVsetXX/GVgetXX pair w/ IOG

Postby kernel » 10 Jan 2016

TJ, thanks for reminding.

here's the testing script.

1. you need to type in six instrument symbols in the code to replace XXXX
2. load this on six 5m charts with different instruments, set "receiver" to true for one, and false for the remaining five.
3. playback all 6 charts altogether to test on a tick by tick mode.

Code: Select all

[IntrabarOrderGeneration = TRUE]

inputs:
receiver(false);

vars:
intrabarpersist BN(0);

arrays:

intrabarpersist symbols[6](""), intrabarpersist lastBar[6,2](0);


Once ((currentbar+MaxBarsBack)>0) begin //only executed once whenever true

//put your six symbols here
symbols[1]="XXXX";
symbols[2]="XXXX";
symbols[3]="XXXX";
symbols[4]="XXXX";
symbols[5]="XXXX";
symbols[6]="XXXX";

for value1=1 to 6 begin
lastBar[value1,1]=value1;
end;

end;


text_new(d[1],t[1],H[1]+minMove, numtostr(C[1]-O[1],0));

if BarNumber<>BN then begin

//broadcast your own info
GVSetNamedInt(symbolroot, C[1]-O[1]);

if receiver then begin
//process other's info

for value1=1 to 6 begin
lastBar[value1,2]=GVGetNamedInt(symbols[value1],-999);
end;

print(newline);

for value1=1 to 6 begin

print("lastBar[", value1, ",2]=", lastBar[value1,2]);

end;


end;

end;


BN=BarNumber;
One thing confused me is, if I put the text_new() line inside the if BarNumber<>BN block, it does not output anything on the chart, why?

The syc issue is, everytime when new bar prints, the outputs for some of the charts are off-by-one-bar, that is, instead of being the C[1]-O[1], they are C[2]-O[2].

What I noticed is, if you remove the "if BarNumber<>BN" test and let it broadcasts tick by tick, once a new bar appears, you'd have to wait after a few tick to get the correct results.

For my situation, I only need to update this piece of info when new bar appears, there's no reason to have this block run tick by tick (waste of computing resource).

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

Re: synchronization issues using GVsetXX/GVgetXX pair w/ IOG

Postby TJ » 10 Jan 2016

Do you have the History Matching turned on?

kernel
Posts: 91
Joined: 19 Feb 2013
Has thanked: 21 times
Been thanked: 4 times

Re: synchronization issues using GVsetXX/GVgetXX pair w/ IOG

Postby kernel » 10 Jan 2016

TJ,

Thanks for the reminding. The Realtime-History Matching option is enabled by default and I leave it that way.

You may try this piece of testing script on your machine and see if your result differs.

I replaced "if BarNumber<>BN then begin" with "if barstatus=0 then begin", didn't help.
Do you have the History Matching turned on?

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

Re: synchronization issues using GVsetXX/GVgetXX pair w/ IOG

Postby TJ » 12 Jan 2016

Please see post #6
[FAQ] Numeric Variables
viewtopic.php?f=16&t=6929


Return to “MultiCharts”