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

[amibroker] Newbie, basic AFL questions



PureBytes Links

Trading Reference Links

First of all, this discussion group (and the software) is GREAT.  
It's so encouraging that such a group of like-minded people
exist.

As soon as I'm up to speed with AFL, I will make sure to
contribute in any way that I can.

Anyway, I'm just starting out with AFL and I'm having trouble
getting my head around a few basic concepts.  I should say that
I've been programming for 15 years, but that obviously hasn't
helped me here!

I've trawled through the historical discussions and also read the 
help files, etc, but I still can't seem to grasp the language 
properly.

Here are my questions…



1. Boolean Expressions

I'm trying to write an Automatic Analysis Script (sorry, I
don't know the correct technical term for this) for issuing buy
and sell signals.

I understand that I need to initiate a `Buy' signal by
assigning a `True' Boolean expression to the implicit
`Buy'
variable such as this…

	Buy = Close[15] > MA(Close,50);

I think I have understood this concept, but please correct me if not.

However, what I can't grasp is why AFL considers the above
Boolean expression to be valid in the given scenario, but it does NOT 
consider it to be a valid Boolean expression in the following 
scenario…

if ( Close[15] > MA(Close,50) )
	Buy = 1;


For this `If' statement, I am given the following error…

Error 3.
Condition in IF, WHILE, FOR statements
has to be Numeric or Boolean type.
You can not use array here,
please use [] (array subscript operator)
to access array elements

Can somebody explain to me why AFL considers the same expression to 
be a valid Boolean expression in the first example but not the second?




2. Previous Closing Price

How do I retrieve the closing price for 15 bars ago?  I want to 
say… "Is this closing price of 15 bars ago greater than the
50 day moving average of today's bar?"

I appreciate that the code I've given so far is clearly wrong
because the it's using the index 15 (i.e. Close[15]).  What I
want to do is something like this…

If ( Close[CurrentBar – 15] > MA(Close,50) )

But I can't figure out how to get a handle to the index of the 
current bar so that I can subtract 15 from it?




3. Boolean Functions

How do I write a Boolean function?

I want to write something like this…

function myBooleanFunction()
{
	myReturnValue = 0;

	if ( expression )
		if ( expression )
			if ( expression )
				myReturnValue = 1;

	return myReturnValue;

}


if ( myBooleanFunction() == 1 )
	Buy = 1;
else
	Sell = 1;


Is this the correct way to write and use a boolean function?

Thanks for your help

Arold





------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/