PureBytes Links
Trading Reference Links
|
Tomasz
I knew there was a way with scripting, I just wanted toknow
if it was possible with AFL !
NB: In fact, that's the beauty of AmiBroker, unlike MetaStock,
every time your are limited with Array formula, you can enter into
scripting.
Anyway, thanks a lot for your quick reply
!
Dali
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Tomasz Janeczko
To: <A title=amibroker@xxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Friday, August 10, 2001 3:24
AM
Subject: Re: [amibroker] Re:New
indicator
Hi Dali,As always there are several possible
solutions to the single problem.Solution 1: ref( buy, -n ) is the fastest,
however it assumes thatthe next buy signal do not occur within n days. An
example would bea system that generates a buy when macd rises above 0and
sells after 5 bars. Since macd( 12, 26 ) will not come back below and
thenabove zero during 5 bars this will workSolution 2: barssince(
buy ) == n, works exactly as you described.Solution 3: The
following JScript sells exactly after 5 bars from initialbuy even if buy
signals are repeated:EnableScript("VBScript");// your buy
formulabuy = Close == HHV( close, 250 ); // buy when prices reaches a new
high<%N = 5 ' sell after 5 barsbuy = AFL( "buy"
)sell = AFL("buy") ' init sell as an array of appropriate size by making a
copybarssincebuy = -1' iterate along the arrayfor i= 0 to
UBound( buy ) sell( i ) = 0 ' if there is no open
trade and buy signal occursinit bar counting if barssincebuy =
-1 then if buy( i ) = 1 then
barssincebuy = 0 end if
else barssincebuy = barssincebuy + 1 if
barssincebuy = N then sell( i )
= 1 barssincebuy = -1
end if end ifnextAFL("sell") =
sell%>buy = exrem( buy, sell );(note that exrem
at the bottom removes excesive buys, you can comment it out to see how
many excesive buy signals are generated)Best regards,Tomasz
Janeczko===============AmiBroker - the comprehensive share
manager.<A
href="">http://www.amibroker.com-----
Original Message ----- From: "Dali" <dali_11@xxxx>To:
<amibroker@xxxxxxxxxxxxxxx>Sent: Friday, August 10, 2001 1:31
AMSubject: Re: [amibroker] Re:New indicator> Randy
:> > the AFL functions syntax is "iif(condition,
array1, array2) " and not> "iff(condition)"> >
Tomasz> > I have similar problem to exit after a buy. I need to
exit a long position N> days after the INITIAL entry point. Is it
possible to do this with AFL ?> > 1st suggested
solution:> sell = ref(buy, -n)> This as the problem generating
trade between a new buy and a sell generated> from a previous buy.For
example given the signal in order of time: [buy1,> buy2, sell1, buy3,
sell2, sell3], it will generate 2 trades [buy1-sell1] and>
[buy3-sell2]. But what I want is [buy1-sell1] and [buy3-sell3] to be>
generate.> > 2nd suggested solution> sell = barssince
(buy) == n> This as the problem of closing the position n day after the
last generated> buy and not the first one.> > Jon>
> ----- Original Message -----> From: "Randy Barlow"
<rcbarlow@xxxx>> To:
<amibroker@xxxxxxxxxxxxxxx>> Sent: Thursday, August 09, 20016:44
PM> Subject: Re: [amibroker] Re:New indicator> > >
> I tried your sell formula and none of the below works.>
>> > Condition1=ref(randy,-2) < ref(low,-2);> >
Condition2=ref(randy,-1) < ref(low,-1);> > buy=Iff(Condition1 AND
Condition2);> > sell = barssince(buy) == 4;> >>
> All I get is "Iff(unknown)" and> > "barssince(buy)
unknown"> >> > Any help appreciated.> >
Randy> >> > ----- Original Message -----> >
From: <tom_supera@xxxx>> > To:
<amibroker@xxxxxxxxxxxxxxx>> > Sent: Thursday, August 09,2001
4:54 PM> > Subject: [amibroker] Re:New indicator>
>> >> > > Hi,> > > What's the
problem?> > >> > > I always use: sell = barssince
(buy) == 3; (3 days for example)> > >> > > Tom
Supera> > >> > >> > >> >
>> > >> > > --- In amibroker@xxxx, Frank
<fesnay@xxxx> wrote:> > > > Hi,> > > >
How about - -> > > >> > > > SellSignal =
barsince(buy);> > > > sell = iif(SellSignal == 5,1,0);>
> > >> > > > This would give you a sell signal on the
fifth day since the buy.> > > > Frank> > >
>> > > > At 03:33 PM 8/9/01 -0400, you wrote:> >
> > >Greetings,> > > > >Let me make sure I
understand this. If I want to sell on the 5th> > > day
after> > > > >a buy occurs, I would use:> > >
> >sell=ref(buy,-5)?> > > > >> > > >
>In order to sell after a certain condition is true for the two>
> > days prior, I> > > > >would use:> >
> > >If Condition1 and Condition2, buy on open next day?>>
> > >> > > > >How would I code this since it also
references yesterday and the> > > day before?> > >
> >> > > > >Randy> > > > >>
> > > >> And back to your request: if you want to sell after 5
bars from> > > buy> > > > >> what you
really want is a NEGATIVE offset:> > > > >> sell = ref(
buy, -5 );> > > > >> this is so because you want to
generate a sell signal knowing> > > that 5 bars> >>
> >ago> > > > >> a buy occurred. You don't need to
look into the future because> > > buy aleady> > >
> >> happened.> > > > >> Best regards,>
> > > >> Tomasz Janeczko> > > > >>
===============> > > > >> > > >
>> > > > >> > > > >> >>
> >> > > > >> > > > >>>
> > >Your use of Yahoo! Groups is subject to> > > <A
href="">http://docs.yahoo.com/info/terms/>
> > > >> > >> > >> >
>> > >> > >> > > Your use of Yahoo!
Groups is subject to> <A
href="">http://docs.yahoo.com/info/terms/>
> >> > >> > >> >>
>> >> >> >> >> > Your use
of Yahoo! Groups is subject to <A
href="">http://docs.yahoo.com/info/terms/>
>> > >
_________________________________________________________> Do You
Yahoo!?> Get your free @yahoo.com address at <A
href="">http://mail.yahoo.com> >
> > > > Your use of Yahoo! Groups is subject
to <A
href="">http://docs.yahoo.com/info/terms/
> > > Your use of Yahoo! Groupsis
subject to the Yahoo! Termsof
Service.
|