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

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



PureBytes Links

Trading Reference Links




I have similar, but maybe not identical, 
requirements.
 
I use Ref(O,1) or Ref(H,1) or Ref(L,1) to look at 
tomorrows action to validate whether my intended STOP or LIMIT order would 
have been filled. Set a flag if so. Then when ref(flag,-1) is set you know that 
today is the day that the order actually fired.
 
e.g if entering long on a buy stop
 
IsTrigger=YourSignal and Ref(H,1) >= 
TargetEntryPrice;
Buy=Ref(IsTrigger,-1);
<FONT face=Arial 
size=2>BuyPrice=max(o,Ref(TargetEntryPrice,-1));
 
Peter K
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=howardbandy@xxxxxxxxx 
  href="">howardbandy 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Saturday, August 02, 2003 8:41 
  AM
  Subject: [amibroker] How Do I --- Move 
  Control of Backtester Trade Settings into the afl System Code
  <FONT face=Arial 
  size=2>How Do I --- Move Control of Backtester Trade 
  Settings into the afl System CodeI 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 
  Entry1.  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 Exit1.  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,HowardSend 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.