Page 1 of 1

Help to check the global variable code

Posted: Aug 11 2012
by Kennedy
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

Re: Help to check the global variable code

Posted: Aug 12 2012
by TJ
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

Re: Help to check the global variable code

Posted: Aug 12 2012
by bowlesj3
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

Re: Help to check the global variable code

Posted: Aug 13 2012
by Kennedy
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

Re: Help to check the global variable code

Posted: Aug 13 2012
by TJ
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.

Re: Help to check the global variable code

Posted: Aug 13 2012
by Kennedy
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

Re: Help to check the global variable code

Posted: Aug 14 2012
by TJ
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?

Re: Help to check the global variable code

Posted: Aug 14 2012
by Kennedy

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?

Re: Help to check the global variable code

Posted: Aug 14 2012
by TJ

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?

Re: Help to check the global variable code

Posted: Aug 14 2012
by Kennedy

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?

Re: Help to check the global variable code

Posted: Aug 14 2012
by TJ

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.

Re: Help to check the global variable code

Posted: Aug 14 2012
by Kennedy
GV is a real time tool. It is not designed for backtest.
.........O,my....
Can ADE do it in portfofio backtest?

Re: Help to check the global variable code

Posted: Aug 14 2012
by evdl
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/v ... =1&t=10663

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

Posted: Aug 14 2012
by Andrew MultiCharts
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.