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
synchronization issues using GVsetXX/GVgetXX pair w/ IOG on
- 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
For code debugging questions,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
please post your code.
Re: synchronization issues using GVsetXX/GVgetXX pair w/ IOG
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.
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).
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;
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).
- 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
Do you have the History Matching turned on?
Re: synchronization issues using GVsetXX/GVgetXX pair w/ IOG
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.
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?
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times