Help to check the global variable code  [SOLVED]

Questions about MultiCharts and user contributed studies.
Kennedy
Posts: 6
Joined: 11 Aug 2012
Has thanked: 4 times

Help to check the global variable code

Postby Kennedy » 11 Aug 2012

In Instrument A(part of codes):

Code: Select all

Num_GV_1 = GVSetInteger(1,1) ;
Num_GV_2 = GVSetInteger(2,1) ;
Num_GV_3 = GVSetInteger(3,1) ;
Num_GV_4 = GVSetInteger(4,1) ;
Num_GV_Shares = GVSetNamedFloat(" SHARES OF INSTRUMENT B", Num_Shares_B ) ;

In Instrument B:

Code: Select all

Num_GV_1 = GVGetInteger(1) ;
Num_GV_2 = GVGetInteger(2);
Num_GV_3 = GVGetInteger(3);
Num_GV_4 = GVGetInteger(4);
Num_Shares_B = GVGetNamedFloat(" SHARES OF INSTRUMENT B", -999.99);

//*****************************************************************************

if Num_GV_1 = 1  then buy Num_Shares_B contracts this bar at close ;
if Num_GV_2 = 1  then buytocover this bar at close ;
if Num_GV_3 = 1  then sellshort Num_Shares_B contracts this bar at close ;
if Num_GV_4 = 1  then sell this bar at close ;

//*****************************************************************************

Value1 = Ticks ; { force RadarScreen to update every tick }
//*********************************************************


With the code, I cant get any singal in Instrument B, but In Instrument A I have singals.
So, what's wrong with it.

The other quesiton is :
About global variable,how can I get more document to let me understand it and use it?

Sincerely

User avatar
TJ
Posts: 6598
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1909 times

Re: Help to check the global variable code

Postby TJ » 12 Aug 2012

Kennedy wrote:In Instrument A(part of codes):...
With the code, I cant get any singal in Instrument B, but In Instrument A I have singals.
So, what's wrong with it.

The other quesiton is :
About global variable,how can I get more document to let me understand it and use it?

Sincerely


can't tell you much with what you have provided.

you have to split the code to find out where did the signal break down.

As far as the code goes, the GVGetNamedFloat should work. The problem is not in the GV code.
Have you tested the GV installation with some sample codes? If the sample codes work, then the GV installation is ok, otherwise you have to review your computer installation.



ps. read up on
buy this bar on close

EasyLanguage Essentials Programmers Guide
Strategy Order Syntax.... pg 80
These users thanked the author TJ for the post:
Kennedy

bowlesj3
Posts: 2028
Joined: 21 Jul 2007
Has thanked: 174 times
Been thanked: 405 times

Re: Help to check the global variable code

Postby bowlesj3 » 12 Aug 2012

About global variable,how can I get more document to let me understand it and use it?

This link has a document on the technicals of GVs if I remember correctly. It has a document on EL collections too. I made an update to the EL collections document and it is farther down the thread. I think there is an MS-Word document on the GVs in the zip file Damage Boy created. If not I can attach the one I have (not totally sure where I got it). It tells you the number of GVs you can have of each type, etc.
viewtopic.php?=&p=8189
These users thanked the author bowlesj3 for the post (total 2):
TJKennedy

Kennedy
Posts: 6
Joined: 11 Aug 2012
Has thanked: 4 times

Re: Help to check the global variable code

Postby Kennedy » 13 Aug 2012

Thanks all.
Help me check this out.

In Instrument A :

Code: Select all

variables:
            GV_1 ( 0 );
GV_1 = GVSetNamedInt("test", 1 ) ;
plot1( StdDev(close,20), "testa");


In Insturment B :

Code: Select all

variables:
            GV_1 ( 0 ), test1( 0 ), test2( 0 ) ;
GV_1 = GVGetNamedInt("test", -999 ) ;
if GV_1 = 1 then begin
test1 = close of data1 ;
test2 = StdDev( test1, 20 ) ;
plot1( test2, "test Global Variable" ) ;
end;


I can get indicator in two insturments,but I cant not sure about it.
Is the code correct?

With the code, the code meaning that:
In Instrument A, set GV_1 = 1,in instrument B,receive it as GV_1 = 1. In GV memory,set test=1.
Is that correct?
Sincerely

User avatar
TJ
Posts: 6598
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1909 times

Re: Help to check the global variable code

Postby TJ » 13 Aug 2012

if you want to test out your code, write something simple.
Your GV_1 = 1 and stddev are just confusing yourself.


Do this:

1. from Instrument A, send the close value to GV

2. from Instrument B, get the value from GV, then plot it.

if your code is correct, you will see Instrument A's close plotted on Instrument B's chart.
If not, then your GV installation is corrupted.

Kennedy
Posts: 6
Joined: 11 Aug 2012
Has thanked: 4 times

Re: Help to check the global variable code

Postby Kennedy » 13 Aug 2012

ye,I will try this.
Thank you.
I can get one value through GV.
How it pass every value in my variable?
Here is my code:
Insturment A:

Code: Select all

variables:
            GV_1 ( 0 ), CA( 0 ) ;
CA = CLOSE ;           
GV_1 = GVSetNamedInt("test", CA ) ;
plot1( CA, "CLOSE OF A");


Instrument B:

Code: Select all

variables:
            GV_1 ( 0 ) ;
GV_1 = GVGetNamedInt("test", -999 ) ;
plot1( GV_1, "CLOSE OF A" ) ;


Shoulde I use reset GV function?
Sincerely

User avatar
TJ
Posts: 6598
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1909 times

Re: Help to check the global variable code

Postby TJ » 14 Aug 2012

Kennedy wrote:ye,I will try this.
Thank you.
I can get one value through GV.
How it pass every value in my variable?
Here is my code:
Insturment A:

Code: Select all

variables:
            GV_1 ( 0 ), CA( 0 ) ;
CA = CLOSE ;           
GV_1 = GVSetNamedInt("test", CA ) ;
plot1( CA, "CLOSE OF A");


Instrument B:

Code: Select all

variables:
            GV_1 ( 0 ) ;
GV_1 = GVGetNamedInt("test", -999 ) ;
plot1( GV_1, "CLOSE OF A" ) ;


Shoulde I use reset GV function?
Sincerely

What do you mean by "every value in my variable"?

Have you read the manual?

Kennedy
Posts: 6
Joined: 11 Aug 2012
Has thanked: 4 times

Re: Help to check the global variable code

Postby Kennedy » 14 Aug 2012

TJ wrote:
What do you mean by "every value in my variable"?

Have you read the manual?


I want it can be interactive.
In Instrument A I got a line,but in Instrument B just a line with only one value.
Is that correct result?

User avatar
TJ
Posts: 6598
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1909 times

Re: Help to check the global variable code

Postby TJ » 14 Aug 2012

Kennedy wrote:
TJ wrote:
What do you mean by "every value in my variable"?

Have you read the manual?


I want it can be interactive.
In Instrument A I got a line,but in Instrument B just a line with only one value.
Is that correct result?


are you looking at the chart in real time during the market hour?
or a chart off line?

Kennedy
Posts: 6
Joined: 11 Aug 2012
Has thanked: 4 times

Re: Help to check the global variable code

Postby Kennedy » 14 Aug 2012

TJ wrote:
are you looking at the chart in real time during the market hour?
or a chart off line?


I set GV in portfolio backtesting.
Does it work in backtesing?

User avatar
TJ
Posts: 6598
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1909 times

Re: Help to check the global variable code

Postby TJ » 14 Aug 2012

Kennedy wrote:
TJ wrote:
are you looking at the chart in real time during the market hour?
or a chart off line?


I set GV in portfolio backtesting.
Does it work in backtesing?


GV is a real time tool. It is not designed for backtest.

Kennedy
Posts: 6
Joined: 11 Aug 2012
Has thanked: 4 times

Re: Help to check the global variable code

Postby Kennedy » 14 Aug 2012

TJ wrote:GV is a real time tool. It is not designed for backtest.


.........O,my....
Can ADE do it in portfofio backtest?

evdl
Posts: 400
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 84 times
Been thanked: 123 times

Re: Help to check the global variable code

Postby evdl » 14 Aug 2012

Yes, ADE works in backtesting (in main MC program and portfoliobacktester).

Please keep in mind that if you want to optimise your strategy with ADE you should use only one processor core. Otherwise it will not work. But this is only applicable for optimizing and not backtesting.

See http://www.multicharts.com/discussion/viewtopic.php?f=1&t=10663
These users thanked the author evdl for the post (total 2):
KennedyTJ

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 557 times

Re: Help to check the global variable code  [SOLVED]

Postby Andrew MultiCharts » 14 Aug 2012

TJ wrote:GV is a real time tool. It is not designed for backtest.


In fact the GV were not indeed designed for backtesting, so basically TJ is right. However in this specific case GV should work because Kennedy performs vertical bar-by-bar calculation of the strategy on all of his data series in Portfolio Backtester and when he has GV on first series, he should be able to get those GV when script is calculated on next data series.
These users thanked the author Andrew MultiCharts for the post (total 3):
TJKennedyJoshM


Return to “MultiCharts”