PureBytes Links
Trading Reference Links
|
I have just noticed that TJ may have made an error when he cut and
pasted from the VBscript code that is in the manual to put in his
post.
His 3rd comment line below reads:
// sell = 0 would set the type to numbersell = buy;
it SHOULD read:
// sell = 0 would set the type to number
sell = buy;
That is why some people got the type mismatch error
The code is correct in the manual.
Steve
--- In amibroker@xxxx, "Tomasz Janeczko" <amibroker@xxxx> wrote:
> Hello,
>
> A very similar example is included in the User's Guide: AmiBroker
Formula Language "AFL Scripting Host":
> [code]
> EnableScript("VBScript");
> hh = HHV( close, 250 );
> // buy when prices reaches a new high
> buy = Close == HHV( close, 250 );
>
> // ensure that sell is an array,
> // sell = 0 would set the type to numbersell = buy;
>
> <%
> close = AFL("close")
> buy = AFL( "buy" )
> sell = AFL("sell")
> ' this variable holds last buying price
> ' if it is zero it means that no trade is open
> lastbuyprice = 0
> ' iterate along the array
> for i = 0 to UBound( close )
> sell( i ) = 0
> ' Remove Buy signals if trade was already initiated
> if( lastbuyprice > 0 ) then
> buy( i ) = 0
> end if
> ' if there is no open trade and buy signal occurs
> ' get the buying price
> if ( lastbuyprice = 0 ) AND (buy( i ) = 1) then
> lastbuyprice = close( i )
> end if
> ' if trade is open and sell condition is valid
> ' generate sell signal
> ' and close the trade
> if (lastbuyprice >0 ) AND ( close( i ) > ( 1.1 *
lastbuyprice ) ) then
> sell( i ) = 1
> lastbuyprice = 0
> end if
> next
> AFL("buy") = buy
> AFL("sell") = sell
> %>
> buy = buy;
>
> [/code]
>
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message -----
> From: "sidleysh" <steves@xxxx>
> To: <amibroker@xxxx>
> Sent: Thursday, July 11, 2002 10:29 AM
> Subject: [amibroker] 'remebering' a value
>
>
> > I have a simple AFL problem (as a newbie), which is
straightforward
> > in traditional languages, but I cant seem to find a solution in
AFL
> >
> > 1) I want to generate a buy when condition is true.
> > 2) After that I want to buy every time the closing price is x%
higher
> > than the price of my previous buy.
> >
> > Because I cant 'store' the price of the previous buy, I do not
how to
> > do this.
> >
> > Any ideas?
> >
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
> >
|