[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Help understanding Arrays



PureBytes Links

Trading Reference Links

Right Paul, no loops required. I believe the user was just trying to
"understand" what was happening by using the loop so I was showing the
problem with the loop, which is an easy one to make. The simple solution
is just:

Buy = Cross( MACD(12,26), Signal(9) );

Better yet, store the T/A for subsequent use in Sell, Short, Cover, Plot
statements, etc.

md = MACD(12,26); 

sig = Signal(9);

Buy = Cross( md, sig );

 

As for "Buy" is an array, I already noted Fred's original statement "Buy
is a light switch, either 0 or 1".

--

Terry

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
Behalf Of Paul Chivers
Sent: Saturday, October 14, 2006 22:11
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Help understanding Arrays

 

Of course, you don't need loops to do what Jerry's doing anyway

BUT!!!

"Buy" is an array of true/false values (ignoring scaling etc) NOT an
array of High prices

so Jerry is still going to come unstuck.

 

 

----- Original Message ----- 

From: Terry <mailto:MagicTH@xxxxxxxxxxx>  

To: amibroker@xxxxxxxxxxxxxxx 

Sent: Sunday, 15 October 2006 11:47 AM

Subject: RE: [amibroker] Help understanding Arrays

 

The thing you are missing in the below is you have FORGOTTEN to use the
subscript in your loop, thus you are setting the ENTIRE ARRAY to True.
The last line of your loop should look like this and it will do what you
are expecting.

 

            {

            Buy[i] = H[i];

}

 

Actually, this is technically incorrect because, as Fred said, Buy is a
light switch, either 0 or 1. This sets Buy to the High. However it still
works because Amibroker treats ANY NON-ZERO Number as true, even a
negative one.

 

PS: I hope you are taking Fred's advice about not buying at the high ;-)

--

Terry

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
Behalf Of laster
Sent: Saturday, October 14, 2006 11:21
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Help undestanding Arrays

 

Hi,

Still trying to figure out working with Arrays, and it's apparent there
is something I am not getting.

My understanding of the following is: If in the i bar the cross of the
MACD was true, then Buy at the High. However, Amibroker is buying in
several circumstances (including when the condition is true).

Can somebody smarter than me please translate the following formula into
English so I can finally get it?

Thanks a lot again,

Jerry

 

 

Reason= Cross( MACD(12,26), Signal(9) );

for( i = 0; i < BarCount; i++ ) 

{

if (Reason[i] == True)

            {

            Buy = H;

}

}



__________ NOD32 1.1803 (20061013) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

 


Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.27/517 - Release Date: 11/3/2006