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

Re: [amibroker] Re: Simple Buy on Close, Sell on Open not as expected


  • Date: Mon, 01 Feb 2010 16:43:57 -0500
  • From: Keith McCombs <kmccombs@xxxxxxxxxxxx>
  • Subject: Re: [amibroker] Re: Simple Buy on Close, Sell on Open not as expected

PureBytes Links

Trading Reference Links



Bruce --
You Win.  That did the trick.
Now to see if it is trying to tell us something.
Early "playing around" indicates there may be some money to be made while sleeping.
-- Keith


Bruce wrote:
 



Keith -

Short followup. Had some time last night to think about what might be different with your setup. These types of issues with dup'ing results are why I originally did BoilerPlate.afl and put it on AmibrokerU.com.

So, the following code puts everything in a known state (as much as is possible), and then sets the options and trade delays. I believe that this matches your goal - buy every day at close and sell the next day at the open -

#include <Boilerplate.afl>
Buy = 1;
Sell = Short = Cover = 0;
BuyPrice = Close;
SellPrice = Open;

SetOption( "ActivateStopsImmediately", False );
SetOption( "AllowSameBarExit", True );

SetTradeDelays( 0, 0, 0, 0 );
ApplyStop( stopTypeNBar, 1, 0, 0, False, 0 );

--- In amibroker@xxxxxxxxxps.com, "Bruce" <brucer@xxx> wrote:
>
> Keith -
>
> Works for me. Make sure that your trade delays are set to 0, or add
>
> SetTradeDelays( 0, 0, 0, 0 );
>
> -- Bruce
>
> --- In amibroker@xxxxxxxxxps.com, Keith McCombs <kmccombs@> wrote:
> >
> > Bruce --
> > Sorry, that doesn't do it. All the sell prices are of the open for the
> > SAME day as the buy, not the NEXT day.
> > Same result as:
> > |*Buy* = 1;
> > *Short* = *Cover* = 0;
> > *Sell* = 1;
> > *BuyPrice* = *Close*;
> > *SellPrice* = *Open*;
> > SetOption("AllowSameBarExit", *True*);|
> >
> > without the |ApplyStop(*stopTypeNBar*, 1, 0, 0, *False*, 1);|
> > -- Keith
> >
> > Bruce wrote:
> > >
> > >
> > >
> > >
> > > Keith -
> > >
> > > Perhaps this way will work better for you -
> > >
> > > Buy = 1;
> > > Sell = Short = Cover = 0;
> > > BuyPrice = Close;
> > > SellPrice = Open;
> > > SetOption( "AllowSameBarExit", True );
> > > ApplyStop( stopTypeNBar, 1, 0, 0, False, 0 );
> > >
> > > BTW, I don't know your motivation for doing this. But, I did something
> > > similar a while back to explore the percentage of the Close to Close
> > > moves that were overnight vs. during the day, and then the persistency
> > > of the direction. It raises some interesting questions.
> > >
> > > -- BruceR
> > >
> > > --- In amibroker@xxxxxxxxxps.com <mailto:amibroker%40yahoogroups.com>,
> > > B S <bs2167@> wrote:
> > > >
> > > > Anthony- Off-topic question if you don't mind - what do the numbers
> > > in parantheses next to "Long" in the Trade column signify?
> > > >
> > > > Â
> > > >
> > > >
> > > >
> > > > ________________________________
> > > > From: Anthony Faragasso <ajf1111@>
> > > > To: amibroker@xxxxxxxxxps.com <mailto:amibroker%40yahoogroups.com>
> > > > Sent: Sat, January 30, 2010 1:36:51 PM
> > > > Subject: Re: [amibroker] Simple Buy on Close, Sell on Open not as
> > > expected
> > > >
> > > > Â
> > > > ----- Original Message -----
> > > > >From: Keith McCombs
> > > > >To: amibroker@xxxxxxxxx ps.com
> > > > >Sent: Saturday, January 30, 2010 12:54 PM
> > > > >Subject: Re: [amibroker] Simple Buy on Close, Sell on Open not as
> > > expected
> > > > >
> > > > >Anthony --
> > > > >Thanks for your effort. I tried your exact code (copy and
> > > paste). It still skips every other day.
> > > > >
> > > > >Also, I reduced the code to absolute minimum as:
> > > > >Buy= 1;
> > > > >BuyPrice= Close;
> > > > >Sell= Ref(Buy, -1);
> > > > >SellPrice= Open;
> > > > >
> > > > >Been through my settings many times. Still the same.
> > > > >
> > > > >
> > > > >BTW, I'm running 5.26beta.
> > > > >
> > > > >-- Keith
> > > > >
> > > > >
> > > > >Anthony Faragasso wrote:
> > > > >Â
> > > > >>Keith
> > > > >>
> > > > >>give this a try:
> > > > >>
> > > > >>Settings window:
> > > > >>
> > > > >>allow same bar exit is enabled
> > > > >>all stops are disabled
> > > > >>
> > > > >>In the trades window of the settings I set up the trades as
> > > follows probably do not need it :
> > > > >>buy=close, delay 0;sell=open, delay 0
> > > > >>short=close, delay 0 ,cover = open, delay 0
> > > > >>// BuyClose SellOpen Daily.afl
> > > > >>SetTradeDelays(0,0,0,0);
> > > > >>Buy = Ref(Close,-1);
> > > > >>BuyPrice = ValueWhen(Buy,Ref(C,-1));
> > > > >>Sell = Open;
> > > > >>SellPrice = Open;
> > > > >>Short = Cover = False; // long only strategy
> > > > >>Â
> > > > >>----- Original Message -----
> > > > >>>From: Keith McCombs
> > > > >>>To: amibroker@xxxxxxxxx ps.com
> > > > >>>Sent: Saturday, January 30, 2010 1:09 AM
> > > > >>>Subject: [amibroker] Simple Buy on Close, Sell on Open not as
> > > expected
> > > > >>>
> > > > >>>Â
> > > > >>>Just fooling around with a very simple idea, but can't get the
> > > code to work.
> > > > >>>The idea is to sell at close of every day, hold over night, and
> > > sell at open the following day.
> > > > >>>Code below sorta works, but skips every other day. For example:
> > > > >>>Day 1, buy on close; Day2, sell on open.
> > > > >>>Day 3, buy on close; Day4, sell on open.
> > > > >>>etc.
> > > > >>>But I can't make it buy on close of days 2, 4, etc.
> > > > >>>Tried "Allow same bar exit" in settings, but that makes it sell
> > > the same day that it buys, which is wrong.
> > > > >>>
> > > > >>>// BuyClose SellOpen Daily.afl
> > > > >>>SetTradeDelays(0,1,0,0);Â Â // has no effect
> > > > >>>Buy= Close;
> > > > >>>BuyPrice= Close;
> > > > >>>Sell= Open;
> > > > >>>SellPrice= Open;
> > > > >>>Short= Cover= False; // long only strategy
> > > > >>>Buy= ExRem(Buy, Sell);Â Â // has no effect
> > > > >>>Sell= ExRem(Sell, Buy);Â Â // has no effect
> > > > >>>
> > > > >>>Well?
> > > > >>>-- Keith
> > > > >>>
> > > >
> > >
> > >
> >
>



__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___