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

[amibroker] HOW TO WRITE BACKTEST CODE FOR "BUY $ XYZ WORTH IN AM"



PureBytes Links

Trading Reference Links

I am trying to create formulas I can use in
bbacktestingand optimization.  I make my decisions
with end of day data, then execute at the AM opening. 
I had done some optimizations, and wanted to translate
the following code over to my oonlinebroker:

PPositionSize= -12;
Buy = Cross(StochK12,3), 30);

	But when I tried to use the formula in real trades, I
realized that I was trying to instruct my broker to
buy a certain dollars worth of ticker XXYZ  But my
broker can only accept an order for a certain number
of shares of ticker XXYZ  (Are all brokers that way?) 
So I starting taking last nights closing price and
dividing it into the position size--12% of the market
value of last night's portfolio--and rounding down to
get the number of shares to purchase.  But now I have
to redo the optimization by putting in a stop order so
I won't exceed the cash I have in my account if
tomorrow AAM'sopening jumps up, say 5% above last
night's close.  Can somebody tell me how to code for
this in AAFL so I can then bbacktesta more realistic
set of code.  My first thought is just to put in a
Limit Order at, say 103% of last night's close.  But
what if I have enough cash to make several buys that
morning?  I would need to take my cash position last
night, divide by the number of purchases, add that
number to each ticker's close last night, and set that
amount as the limit order (remembering to figure in
commissions.)  Could somebody please help me code all
that so I can do a proper bbacktestand optimization? 
Thank you in advance for any help you can give me. 


		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/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/