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

[amibroker] Re: What's AFL for 'selling on close 3 days later'



PureBytes Links

Trading Reference Links


Ah, I eventually got it. I do want to buy every bar; I want to buy at
every close and sell at the 2nd open after. I was able to do it with:

Sell = ExRemSpan(Buy,2);
SellPrice = Open;

Then it does sell at the open 2 days later like I want. But my next
question is if I add at the beginning:
SetPositionSize(50, spsPercentOfEquity);

How come it waits until the 1st trade closes before initiating another
trade? I would expect it to:

Day 1: Buy with 50% equity (Trade 1)
Day 2: Buy with other 50% equity (Trade 2)
Day 3: Sell at open Trade, Buy at close with Trade 3, etc.

What I have for AFL is:
SetPositionSize(50, spsPercentOfEquity);
Buy = 1;
BuyPrice = Close;
Sell = ExRemSpan(Buy,2);
SellPrice = Open;

Thanks a ton for all the help,

Joel

--- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxxx> wrote:
> you are creating the buy for every bar by using Buy=1;
> Add this line
> 
> exremspan(buy,2);
> 
> this will stop the buy signals for 2 bars.
> 
> 
> 
> 
> 
> On Apr 1, 2005 7:29 AM, onlyobsession2k3 <jmpatton@xxxx> wrote:
> > 
> > 
> > I'm still struggling with this.. So wouldn't the following code
> > perform a buy, and then sell at the open 2 days later? It still
> > reports the buys & sells on the same day when I run it.
> > 
> > Buy = 1;
> > BuyPrice = Close;
> > Sell = Ref(Buy,-2);
> > SellPrice = Open; // or should this be SellPrice = Ref(Open,-2)?
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, Terry <MagicTH@xxxx> wrote:
> > > Said another way, you can't buy in the future, so you have to be
in the
> > > future and look back 3 days to see if there is a buy for today
> > > (3 days into the future from 3 days ago.) Get it?
> > >
> > > Terry
> > >
> > > Graham wrote:
> > >
> > > >the post wanted to sell 3 days after the buy, so the ref needs
to look
> > > >back 3 days, so
> > > >Sell = Ref(Buy,-3);
> > > >
> > > >Defining the buyprice and sellprice can be done in the AA
settings, or
> > > >using SellPrice and BuyPrice
> > > >If you want to buy on close one day and seel at open the next
then as
> > > >I posted before there are various ways to code this.
> > > >
> > > >On Mar 31, 2005 10:19 AM, onlyobsession2k3 <jmpatton@xxxx> wrote:
> > > >
> > > >
> > > >>I'm new to AFL so forgive if these questions seem simple:
> > > >>
> > > >>1) Regarding the post below, the AFL Function reference says
that in
> > > >>the Ref function, a positive number refers to the future, so
wouldn't
> > > >>"three days later" be Ref(Close,3) and not -3? Is the help
> > > >>documentation incorrect?
> > > >>
> > > >>2) How would I write a simple formula like "Buy on Close, Sell on
> > > >>Open"? I tried the following, but it seems to buy & sell on the
> > same day?
> > > >>Buy=Close
> > > >>Sell=Ref(Open,-1)
> > > >>
> > > >>
> > > >>--- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxxx>
wrote:
> > > >>
> > > >>
> > > >>>check the help screens for AFL functions
> > > >>>
> > > >>>it sets the delays for (buy,sell,short,cover)
> > > >>>
> > > >>>
> > > >>>On Tue, 29 Mar 2005 14:06:07 -0000, Dickie Paria <babui@xxxx>
wrote:
> > > >>>
> > > >>>
> > > >>>>Thanks - the 'sell=ref(buy,-3)' worked just fine.  Quick qts
- what
> > > >>>>is the 'zeros' mean in 'settradedelays(0,3,0,0)?  Is it H,L,O ?
> > > >>>>
> > > >>>>--- In amibroker@xxxxxxxxxxxxxxx, "W Schmidt"
<william.schmidt@xxxx>
> > > >>>>wrote:
> > > >>>>
> > > >>>>
> > > >>>>>On Tue, 29 Mar 2005 06:28:51 +0800, Graham <kavemanperth@xxxx>
> > > >>>>>
> > > >>>>>
> > > >>>>wrote:
> > > >>>>
> > > >>>>
> > > >>>>>>A few ways of doing it
> > > >>>>>>
> > > >>>>>>buy = exremspan(buy,3);
> > > >>>>>>sell = ref(buy,-3);
> > > >>>>>>
> > > >>>>>>or
> > > >>>>>>
> > > >>>>>>settradedelays(0,3,0,0);
> > > >>>>>>sell = buy;
> > > >>>>>>
> > > >>>>>>there are more ways to do it as well.
> > > >>>>>>
> > > >>>>>>
> > > >>>>>>On Mon, 28 Mar 2005 21:13:52 -0000, Dickie Paria <babui@xxxx>
> > > >>>>>>
> > > >>>>>>
> > > >>>>wrote:
> > > >>>>
> > > >>>>
> > > >>>>>>>//IF X=1 THEN Buy Next Bar AT C+.05 STOP;
> > > >>>>>>>Buy=Ref(x,-1);
> > > >>>>>>>BuyPrice=Ref(C+.05,-1);
> > > >>>>>>>Sell=Ref(x,-1);
> > > >>>>>>>SellPrice=Close;
> > > >>>>>>>
> > > >>>>>>>The above is for selling on close on the same day you
bought a
> > > >>>>>>>particular stock/future.  How would you write the above -
if you
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>wanted
> > > >>>>
> > > >>>>
> > > >>>>>>>to sell on close 3 days after a buy?  Thanks
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>
> > > >
> > > >
> > 
> > 
> > Please note that this group is for discussion between users only.
> > 
> > To get support from AmiBroker please send an e-mail directly to
> > SUPPORT {at} amibroker.com
> > 
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> > 
> > 
> > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> 
> 
> -- 
> Cheers
> Graham
> http://e-wire.net.au/~eb_kavan/





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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