GVSetNamedInt, GVGetNamedInt

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

GVSetNamedInt, GVGetNamedInt

Postby kernel » 08 Mar 2015

Hi,

When GVSetNamedInt and GVGetNamedInt were used to pass values from low resolution time frame to high resolution time frame, saying, 5m as the sender and 1m as the receiver, it worked fine. However, I couldn't get it work on the reverse direction, i.e., 1m as the sender, 5m as the receiver. Were they designed as so or anything I missed? thanks.

-K

User avatar
JoshM
Posts: 2099
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1504 times
Contact:

Re: GVSetNamedInt, GVGetNamedInt

Postby JoshM » 09 Mar 2015

When GVSetNamedInt and GVGetNamedInt were used to pass values from low resolution time frame to high resolution time frame, saying, 5m as the sender and 1m as the receiver, it worked fine. However, I couldn't get it work on the reverse direction, i.e., 1m as the sender, 5m as the receiver. Were they designed as so or anything I missed? thanks.
They should work in either direction. Were both scripts updating continously, either by checking the option 'update on every tick' (for indicators) or with RecalcLastBarAfter?

When, for example, both scripts are calculated on bar close only, the 1m sender would submit five `GVSetNamedInt` updates before the 5m receiver would be able to access one value through `GVGetNamedInt` (since the 5m receiver would only pull or set a global variable every 5 minutes).

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

Re: GVSetNamedInt, GVGetNamedInt

Postby kernel » 09 Mar 2015

They should work in either direction. Were both scripts updating continously, either by checking the option 'update on every tick' (for indicators) or with RecalcLastBarAfter?

When, for example, both scripts are calculated on bar close only, the 1m sender would submit five `GVSetNamedInt` updates before the 5m receiver would be able to access one value through `GVGetNamedInt` (since the 5m receiver would only pull or set a global variable every 5 minutes).
I set IntraBarOrderGeneration to true in both the 1m and 5m scripts, so the updating frequency should be tick by tick, regardless who the sender/receiver is, right?

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

Re: GVSetNamedInt, GVGetNamedInt

Postby kernel » 09 Mar 2015

ran a quick test as follows:

30m (indicator, sender/receiver) script:

Code: Select all

[IntraBarOrderGeneration = TRUE]

vars:

dat30(30);

//send
GVSetNamedInt("d30",dat30);


//recieve

print("30m: d1=", GVGetNamedInt("d1",-999), " dat30=", dat30);

5m (indicator, sender/receiver) script:

Code: Select all

[IntraBarOrderGeneration = TRUE]

//send
GVSetNamedInt("d5",5);


//recieve

print("5m: d1=", GVGetNamedInt("d1",-999));


1m (signal, sender/receiver) script:

Code: Select all

[IntraBarOrderGeneration = TRUE]

vars:
dat1(0);

dat1=dat1+1;

//send
GVSetNamedInt("d1",1);


//recieve
print("1m: d5=", GVGetNamedInt("d5",-999), " d30=", GVGetNamedInt("d30",-999), " dat1=", dat1);

apply 30m, 5m, and 1m to 30m, 5m and 1m chart respectively.

output:

Code: Select all

1m: d5= 5.00 d30= 30.00 dat1= 1.00
1m: d5= 5.00 d30= 30.00 dat1= 1.00
1m: d5= 5.00 d30= 30.00 dat1= 1.00
1m: d5= 5.00 d30= 30.00 dat1= 1.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
1m: d5= 5.00 d30= 30.00 dat1= 2.00
1m: d5= 5.00 d30= 30.00 dat1= 3.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 4.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 4.00
1m: d5= 5.00 d30= 30.00 dat1= 4.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 4.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 4.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 4.00
30m: d1= 1.00 dat30= 30.00
1m: d5= 5.00 d30= 30.00 dat1= 4.00
even with IntraBarOrderGeneration set to TRUE, dat1 was not updated on every tick, i.e., the script was not run on every incoming tick. What have I missed?

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

Re: GVSetNamedInt, GVGetNamedInt

Postby kernel » 09 Mar 2015

then I added one line in the 30m script to have its data "dat30" incremented on each run:

Code: Select all

[IntraBarOrderGeneration = TRUE]

vars:

dat30(30);

dat30=dat30+1;

//send
GVSetNamedInt("d30",dat30);


//recieve

print("30m: d1=", GVGetNamedInt("d1",-999), " dat30=", dat30);
5m and 1m scripts were same as before.

output:

Code: Select all

1m: d5= 5.00 d30=3350.00 dat1= 3.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
30m: d1= 1.00 dat30=3350.00
5m: d1= 1.00
dat30 got assigned to 3350, a number I have no idea where it came from. any one has any clue? thanks.

User avatar
TJ
Posts: 7266
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 992 times
Been thanked: 2063 times

Re: GVSetNamedInt, GVGetNamedInt

Postby TJ » 09 Mar 2015

You can study my code for a quick start

GlobalVariables GV Latency Tester
viewtopic.php?f=5&t=10780

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

Re: GVSetNamedInt, GVGetNamedInt

Postby kernel » 09 Mar 2015

You can study my code for a quick start

GlobalVariables GV Latency Tester
viewtopic.php?f=5&t=10780
already did, appreciated, but still couldn't figure out.


Return to “MultiCharts”