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

[amibroker] Re: Simple Buy and Hold System



PureBytes Links

Trading Reference Links

Hi Brian

> Do you want the B&H as well as a comparison?

Yes. Actually its the other way around. I would like to do the system
test I mentioned in post 117721 and use the B&H as a comparison. I
thought about my previous reply to you and forgot to mention that the
Buy & Hold was needed as well to do a comparison against the system test.

I apologize for the confusion.

Thanks Brian
Walter

--- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@xxx> wrote:
>
> > I'm back testing someone's basic SMA system. I jsut want to see
> > returns of his system over a longer period of time.
> 
> O.K 
> 
> But that's not buy & hold - that is a system test.
> Do you want the B&H as well as a comparison?
> 
> brian_z
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Walter Lepore" 
> <electricwally77@> wrote:
> >
> > 
> > 
> > Hi Brian
> > 
> > >>Q1. Where do you want to use the answer? 
> > 
> > I'm back testing someone's basic SMA system. I jsut want to see
> > returns of his system over a longer period of time.
> > 
> > >> Q2. How much money have you got to spend i.e. what is your 
> initial 
> >  equity?
> > 
> > Start with $100,000.
> > 
> > >> Q3. The first bar has a lot of points on it - everything equal to
> > and between the high and the low. Which data point do you mean - 
> Open, 
> > Close, High, Low or something else?
> > 
> > I understand the data points but not sure of your question. I simply
> > would like to buy at the open on the first bar or even on the close 
> or
> > anywhere on the first bar. Its really not that important(I think). 
> > Not sure about the exit. This is where it gets fuzzy. I assume the
> > exit would be to sell on the most recent bar (last bar in the data) 
> to
> > close out the position. 
> > 
> > Thus I guess its not called buy and hold because if we sell it we
> > close the position. However we did actually Buy and Hold it from 
> 1962
> > to 2007. Whatever....I'm confused.    
> > 
> > I'm just trying to test a system I was presented with that has 3 
> SMA's
> >  for example, let's just call them the following (40 day SMA, 80 day
> > SMA and 200 day SMA). The system only buys (enters long)on the next
> > morning when the stock closes the previous day above all three SMA's
> > and sells the next morning (exits long) when the stock closes the
> > previous day below all three SMA's. If we are long the stock and it 
> is
> > trading within the three moving averages then it is simply a HOLD 
> (no
> > action). 
> > 
> > I'm testing it on all the data available on HPQ (Hewlitt Packard)
> > downloaded from yahoo.
> > 
> > >>> If you can answer them I'll see if I can give you a quick answer
> > to get you going while you take your time to take in the full AA 
> picture.
> > 
> > Okay Brian. Sounds good.
> > 
> > Thanks for all your time.
> > Walter
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@> wrote:
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Walter Lepore" 
> > > <electricwally77@> wrote:
> > > >
> > > > Hi Brian
> > > > 
> > > > I appreciate all the help. I guess -at this point- my specific
> > > > question would be how and what are the correct settings in the 
> AA
> > > > "settings" window under the tabs called;
> > > > General,Trades,Stops,Report,Portfolio
> > > > 
> > > > The help file tells me to set the min. shares to 1 yet I 
> believe you
> > > > said to set it to 0.0001. I'm confused. Sorry 'bout that. 
> > > > 
> > > > I really need to sit down and dig into the help files and 
> figure how
> > > > and why to set the parameters in the "settings" window.
> > > > 
> > > > All I'm trying to accomplish (please bear with me) is to create 
> a 
> > > simple 
> > > > "buy on first bar" and "sell on last bar". 
> > > 
> > > Q1. Where do you want to use the answer?
> > > 
> > > Do you just want to plot it or what (to start with)?
> > > 
> > > 
> > > Q2. How much money have you got to spend i.e. what is your 
> initial 
> > > equity?
> > > 
> > > Q3. The first bar has a lot of points on it - everything equal to 
> and 
> > > between the high and the low. Which data point do you mean - 
> Open, 
> > > Close, High, Low or something else?
> > > 
> > > AA needs to know the answer to questions like this before it can 
> > > proceed.
> > > 
> > > If you can answer them I'll see if I can give you a quick answer 
> to 
> > > get you going while you take your time to take in the full AA 
> picture.
> > > 
> > > 
> > > brian_z
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > I did not know it would be
> > > > this intricate to accomplish. Intricate as defined by a newbie 
> such 
> > > as
> > > > myself.
> > > > 
> > > > I'm using only one stock (HPQ) using daily data from 1962 to 
> > > present.
> > > > The total daily bars are 11,561.
> > > > 
> > > > Let me keep digging. I'll nail it down eventually. I know back 
> > > testing
> > > > involves a rather high learning curve but the payoff is well 
> worth 
> > > it
> > > > once I understand and begin to maneuver around and actually see
> > > > systems work.
> > > > 
> > > > Thanks Brian
> > > > Walter
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@> 
> wrote:
> > > > >
> > > > > If you get stuck come back with a specific question.
> > > > > 
> > > > > You should be able to replicate the outcomes of the code 
> below 
> > > > > (understanding it's principles is the basis of B&H).
> > > > > If you can't let me know.
> > > > > 
> > > > > The only real difference between it and my PDF is that you 
> only 
> > > want 
> > > > > to B&H one stock whereas in the PDF I used three (from 
> memory).
> > > > > 
> > > > > 
> > > > > I'm not necessarily around every day but I will check back on 
> > > this 
> > > > > topic at some stage.
> > > > > 
> > > > > > Filter = 1;
> > > > > 
> > > > > >//In AA settings Initial Equity = 1
> > > > > > //Min shares = 0.0001
> > > > > > //Run on all quotations
> > > > > >
> > > > > > PositionSize = -100;
> > > > > >
> > > > > > Buy =1;
> > > > > > Sell = 0;
> > > > > >
> > > > > > e = Equity();
> > > > > >
> > > > > > AddColumn(e,"equity",1.6,1);
> > > > > >
> > > > > > Plot(e * 28.01,"Equity",1,1);//manually enter the starting 
> > > close for
> > > > > > your symbol
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Walter Lepore" 
> > > > > <electricwally77@> wrote:
> > > > > >
> > > > > > Hi Brian
> > > > > > 
> > > > > > I appreciate all your help. I'm slowly reading and trying to
> > > > > > understand all that you have presented. Please give me some 
> > > time to
> > > > > > figure all this out. I went into my settings in the AA 
> window 
> > > and I 
> > > > > am
> > > > > > making some changes. 
> > > > > > 
> > > > > > First thing I noticed was that "min. shares" was set 
> to .01  
> > > > > > I changed it to 1.
> > > > > > 
> > > > > > I'm reading through some help files as well (in regards to 
> the 
> > > AA
> > > > > > window "settings" button.)
> > > > > > 
> > > > > > I just wanted to send you this quick note to let you know 
> I'm 
> > > > > working
> > > > > > on it.
> > > > > > 
> > > > > > Thank you again
> > > > > > Walter 
> > > > > > 
> > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" 
> <brian_z111@> 
> > > wrote:
> > > > > > >
> > > > > > > Walter,
> > > > > > > 
> > > > > > > Backtesting in the AA window is a simulation of real 
> trading 
> > > > > > > conditions - the trade requires an intitial equity and a 
> > > setting 
> > > > > for 
> > > > > > > the minimum size allowed (one share or part of a share) 
> plus 
> > > > > other 
> > > > > > > settings.
> > > > > > > 
> > > > > > > In my example PDF file I show where and when I accepted 
> the 
> > > > > defaults 
> > > > > > > or changed them (the file is not exact or the be all and 
> end 
> > > all -
> > > > >  it 
> > > > > > > only attempts to convey the main principles involved).
> > > > > > > 
> > > > > > > Using a small training database I selected a symbol that 
> had 
> > > an 
> > > > > > > opening close price of 28.01.
> > > > > > > 
> > > > > > > The I ran the following in AA - with the symbol selected 
> as 
> > > the 
> > > > > > > current symbol in the All Symbols list.
> > > > > > > The AB defaults are accepted except for PositionSize and 
> > > > > MinShares 
> > > > > > > and Intitial Equity i.e. buy is on the Close.
> > > > > > > 
> > > > > > > Equity itself will be a compounded % of the ROC for 1 
> period 
> > > on 
> > > > > the 
> > > > > > > close.
> > > > > > > Multiplying it by the starting close price adjusts equity 
> so 
> > > that 
> > > > > it 
> > > > > > > is relative to the starting close.
> > > > > > > 
> > > > > > > Note: Intitial Eq does not allow decimal places so I 
> chose 1 
> > > > > dollar.
> > > > > > > Then I allowed shares to be purchased in 1/10000th 
> parcels so 
> > > > > that 
> > > > > > > the 1 dollar equity could be apportioned by up to 4 
> decimal 
> > > > > places 
> > > > > > > with accuracy.
> > > > > > > 
> > > > > > > Filter = 1;
> > > > > > > 
> > > > > > > //In AA settings Initial Equity = 1
> > > > > > > //Min shares = 0.0001
> > > > > > > //Run on all quotations
> > > > > > > 
> > > > > > > PositionSize = -100;
> > > > > > > 
> > > > > > > Buy =1;
> > > > > > > Sell = 0;
> > > > > > > 
> > > > > > > e = Equity();
> > > > > > > 
> > > > > > > AddColumn(e,"equity",1.6,1);
> > > > > > > 
> > > > > > > Plot(e * 28.01,"Equity",1,1);//manually enter the 
> starting 
> > > close 
> > > > > for 
> > > > > > > your symbol
> > > > > > > 
> > > > > > > Since the plot simulates buying 1 * the opening close 
> price 
> > > it 
> > > > > > > exactly equals the price chart (which is what I would get 
> if 
> > > I 
> > > > > bought 
> > > > > > > 1 share at the close of the first bar).
> > > > > > > The number of bars doesn't matter since it is never sold 
> in a 
> > > buy 
> > > > > and 
> > > > > > > hold (a little poetry there).
> > > > > > > 
> > > > > > > The same thing can be done other ways:
> > > > > > > 
> > > > > > > for example someone else provides this method ( I won't 
> > > explain 
> > > > > it 
> > > > > > > because it is not mine but I don't see any reason why 
> that 
> > > type 
> > > > > of 
> > > > > > > approach wouldn't work).
> > > > > > > 
> > > > > > > /* now buy and hold simulation */
> > > > > > > Short=Cover= 0;
> > > > > > > Buy=Status(" firstbarintest" );
> > > > > > > Sell=Status( "lastbarintest" );
> > > > > > > SetTradeDelays( 0,0,0,0); PositionSize = -100;
> > > > > > > ApplyStop(0, 0,0,0);
> > > > > > > ApplyStop(1, 0,0,0);
> > > > > > > ApplyStop(2, 0,0,0);
> > > > > > > Plot( Equity( 0, -2 ), "Buy&Hold", -9 );
> > > > > > > }
> > > > > > > 
> > > > > > > 
> > > > > > > brian_z
> > > > > > > 
> > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Walter Lepore" 
> > > > > > > <electricwally77@> wrote:
> > > > > > > >
> > > > > > > > Hi Brian
> > > > > > > > 
> > > > > > > > I thank you for helping.
> > > > > > > > 
> > > > > > > > Based on your advice, here is the code I entered...
> > > > > > > > 
> > > > > > > > _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} 
> Open 
> > > %g, 
> > > > > Hi %
> > > > > > > g,
> > > > > > > > Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, 
> > > SelectedValue
> > > > > ( ROC
> > > > > > > (
> > > > > > > > C, 1 ) ) ));
> > > > > > > > Plot( C, "Close", ParamColor("Color", colorBlack ), 
> > > > > styleNoTitle |
> > > > > > > > ParamStyle("Style") | GetPriceStyle() ); 
> > > > > > > > _SECTION_END();
> > > > > > > > 
> > > > > > > > 
> > > > > > > > Buy = 1;
> > > > > > > > Sell = 0;
> > > > > > > > 
> > > > > > > > I clicked "apply indicator" in the formula window and 
> > > completed 
> > > > > a 
> > > > > > > back
> > > > > > > > test but received some strange results. My trade list 
> in 
> > > the AA 
> > > > > > > window
> > > > > > > > shows 5 trades total. Under the trade column, the first 
> > > trade 
> > > > > says
> > > > > > > > "OUT". 2nd trade says "Long", 3rd trade says "Out", 4th 
> > > trade 
> > > > > says
> > > > > > > > "Long" and the 5th trade says "Out".
> > > > > > > > 
> > > > > > > > I clicked "show actual trades" and it shows a red arrow 
> on 
> > > bar 
> > > > > 1 
> > > > > > > and a
> > > > > > > > green and red arrow on bar 11,560 and a green and red 
> arrow 
> > > on 
> > > > > bar
> > > > > > > > 11,561. 
> > > > > > > > 
> > > > > > > > There are 11,561 bars total (daily data from 1962 to 
> 2007)
> > > > > > > > 
> > > > > > > > Hope you can help please
> > > > > > > > 
> > > > > > > > Thanks Brian
> > > > > > > > Walter
> > > > > > > > 
> > > > > > > > 
> > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" 
> > > <brian_z111@> 
> > > > > wrote:
> > > > > > > > >
> > > > > > > > > Walter,
> > > > > > > > > 
> > > > > > > > > There' more than one way - here's a simple one.
> > > > > > > > > 
> > > > > > > > > buy = 1;
> > > > > > > > > sell = 0;
> > > > > > > > > 
> > > > > > > > > There's an extended example in the files section of 
> this 
> > > > > message 
> > > > > > > > > board.
> > > > > > > > > 
> > > > > > > > > Files > CompareIndexToPortfolio
> > > > > > > > > 
> > > > > > > > > brian_z
> > > > > > > > > 
> > > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Walter Lepore" 
> > > > > > > > > <electricwally77@> wrote:
> > > > > > > > > >
> > > > > > > > > > Hi Members
> > > > > > > > > > 
> > > > > > > > > > Please bear with me. I am trying to write a simply 
> Buy 
> > > and 
> > > > > Hold 
> > > > > > > > > system
> > > > > > > > > > using only one stock (HPQ-Hewlitt Packard). I'm 
> using 
> > > End 
> > > > > of 
> > > > > > > Day  
> > > > > > > > > data
> > > > > > > > > > and programming using the AFL Wizard . I've been at 
> it 
> > > for 
> > > > > > > about two
> > > > > > > > > > hours but can't generate the results of a simple 
> buy & 
> > > Hold.
> > > > > > > > > > 
> > > > > > > > > > Obviously I'm doing something wrong.  There are a 
> total 
> > > of 
> > > > > > > 11,561
> > > > > > > > > > Daily bars in the data I downloaded from Yahoo.
> > > > > > > > > > 
> > > > > > > > > > I've built several different formulas and none of 
> them 
> > > > > result 
> > > > > > > in a
> > > > > > > > > > simple Buy and Hold when I backtest and run a 
> report.
> > > > > > > > > > 
> > > > > > > > > > Can someone please tell me what the code is for a 
> > > simple 
> > > > > buy 
> > > > > > > and 
> > > > > > > > > hold
> > > > > > > > > > please?
> > > > > > > > > > 
> > > > > > > > > > I assume there will only be an "Enter Long" but 
> > > NO "Exit 
> > > > > Long" 
> > > > > > > since
> > > > > > > > > > I'm still holding. Correct?  
> > > > > > > > > > 
> > > > > > > > > > Thank you very much
> > > > > > > > > > Walter
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>




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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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