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

Re: 'remebering' a value



PureBytes Links

Trading Reference Links

hi tomasz,

i am interested in the same type of prob as what the previous poster 
posted.

Why does your code give me error messages.


Source: Microsoft VBScript runtime error
Line: 18 Char: 1
Error: 0 - Type mismatch: 'Sell'

it happens at this line in the code of youre formula below.
for i = 0 to UBound( Close )
Sell( i ) = 0

thanks pete.






--- 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/ 
> > 
> > 
> >