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

[amibroker] How Do I --- Move Control of Backtester Trade Settings into the afl System Code



PureBytes Links

Trading Reference Links

How Do I --- Move Control of Backtester Trade Settings into the afl 
System Code


I have a trading system that uses both profit target and stop loss, 
along with a "normal" system exit.  I am using end of day data and 
will be processing after the close, then placing my order(s) before 
the open of the next day.  

How do I code this into AmiBroker so that 
A.  the BackTester properly accounts for the trades that would have 
actually taken place; and also  
B.  Explorer indicates that I should place orders for the next day, 
and at what price?

The code should work correctly without regard to the Backtester 
Settings of when to trade and how much delay. 

Specific (but somewhat artificial) example:

Trade Entry
1.  Do anything to enter the trade -- for example buy at the next 
open when today's close crosses up through the 50 day moving average 
of close.

Trade Exit
1.  Compute some indicators and test some conditions within the 
system, If Condition AAA (normal exit), then place a Market Order -- 
that is an order to sell at the next open.  If Condition BBB (profit 
target), then place a Sell Limit Order to sell at some price.  If 
Condition CCC (stop loss), then place a Sell Stop Order to sell at 
some price.  Recall that a Sell Limit Order is placed above the 
market and only filled if the high price is equal to or greater than 
the limit price.  And a Sell Stop Order is placed below the market 
and only filled if the low price is equal to or lower than the stop 
price.
2.  Condition AAA will usually be alone.  Both Condition BBB and CCC 
could be (and usually are) true, so both the Sell Limit Order and 
Sell Stop Order would be active.  
A.  If exactly one of them is filled, report my fill price.  
B.  If two or more of them would have been filled, check the opening 
price.  If it triggered one order, report that price.
C.  If two or more of them would have been filled during the day, 
alert me that I have an "ambiguous day" and cannot tell which would 
have occurred first.  (There may be other Stop and / or Limit orders 
active as well.)  Assume the worst, and report my fill at the worst 
price of the ambiguous orders (Sell Stop price, in this example).
3.  If none of the orders was filled, provide for recalculation of 
the levels for the Limit and Stop order and inform me what they will 
be in case I need to Cancel and Replace them for tomorrow.

Thanks in advance,
Howard




------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/sO0ANB/LIdGAA/ySSFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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