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

[amibroker] How Do I --- Implement Limit Orders



PureBytes Links

Trading Reference Links

How Do I --- Implement Limit Orders

I have a trading system based on pattern recognition.  I am using 
end of day data and will be processing after the close, then placing 
my order before the open of the next day.  When a pattern occurs, I 
want to place a limit order.  After some number of days, if the 
limit order is not filled, I want to withdraw it.  

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 a limit order 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 very artificial) example :

Trade Entry
1.  Whenever today's high is greater than yesterday's high AND 
today's low is lower than yesterday's low AND today's 5 day moving 
average of close is higher than yesterday's 5 day moving average of 
close, then my pattern is true and a buy signal is generated and I 
want to place a limit order for tomorrow.
2.  I want to buy at a limit of 0.99 times the low price on the day 
the buy signal was generated.
3.  I want to place that order for up to three consecutive days.  
A.  If it is filled on any of the days, I want to know exactly what 
my fill price was.  (It could be my limit price, or the open if that 
is lower).
B.  If it is not filled in three days, I want to cancel the order.  
That is, drop the buy signal.
4.  If the pattern occurs a second time before the limit order is 
filled, I want to renew the buy signal, calculate a new limit price, 
and restart the three day clock.

Trade Exit
1.  Once in a trade, exit at the next open when today's close 
crosses down through the 5 day moving average of close.

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/