The code snip below will likely not do exactly what you
want, but it may give you a couple ideas of how to approach
the problem. 

The gist of the code is to combine a IB fee (1/2 cent a
share) with a sliding scale for slippage based on stock
price. A fancier sliding scale would also add additional
slippage for volume below 100,000.

The IB fee is adjusted based on the real close which some
data providers put into AB's OI field. For the code to
work, one has to turn of AB's default range checking that
normally keeps buy and sell prices within the high-low
range for the day.

Here is the code:

//turn off high-low range check 
SetOption("PriceBoundChecking",False);

rClose = OpenInt/100; // OI field from Yahoo or CSI
slippage = 0.01 ; // default 1% slippage
slippage = IIf(rClose >= 10, 0.0025, slippage ); // 1/4%  
slippage = IIf(rClose < 10, 0.0033, slippage ); // 1/3%  
slippage = IIf(rClose < 5, 0.005, slippage ) ; // 1/2%  
slippage = IIf(rClose < 3, 0.0066, slippage ) ; // 2/3%
slippage = IIf(rClose < 2, 0.008, slippage ) ; // 4/5%
slippage = IIf(rClose < 1.5, 0.01, slippage ) ; // 1%

Commission = 0.005 / rClose ; // IB's fee 1/2 cent 
//VIP set commission to 0 on Settings page

ComSlip = Commission + slippage ; //

BuyPrice = ( Open * (1 + ComSlip) ); 
SellPrice = ( Open * (1 - ComSlip) ); 
ShortPrice = ( Open * (1 - ComSlip) ); 
CoverPrice = ( Open * (1 + ComSlip) ); 

--- Terry <[EMAIL PROTECTED]> wrote:

> That should work with a system of fewer trades and higher
> profit/loss
> ratio. But my system has a lot of trades every day and
> profits by higher
> win rate.
> 
> If I use .2% as commissions, it is not as profitable and
> doesn't reflect
> real trading statistics. 
> 
> You are assuming you get zero slippage in your trades
> which is not my
> experience. That said, I'm certain you can do it in the
> custom
> backtester, but I can only point you to the documentation
> for details.
> 
>  
> 
> In Help, Search for: Porfolio Backtester Interface
> 
> Note the misspelling of Portfolio.
> 
> --
> 
> Terry
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Mark H
> Sent: Thursday, April 06, 2006 19:36
> To: [email protected]
> Subject: Re: [amibroker] How to simulate IB commission?
> 
>  
> 
> That should work with a system of fewer trades and higher
> profit/loss
> ratio. But my system has a lot of trades every day and
> profits by higher
> win rate.
> 
> If I use .2% as commissions, it is not as profitable and
> doesn't reflect
> real trading statistics. 
> 
>  
> 
> I looked at the advanced portfolio backtester, but it
> doesn't seem to
> have any place you can set commission based on trade
> info. (The trade
> object does have a GetCommission() method, but not
> SetCommission()). 
> 
>  
> 
> Probably I have to stick with Wealth-Lab for a while. But
> its
> backtesting is painfully slow...
> 
>  
> 
> ----- Original Message ----- 
> 
> From: Terry <mailto:[EMAIL PROTECTED]>  
> 
> To: [email protected] 
> 
> Sent: Thursday, April 06, 2006 8:31 PM
> 
> Subject: RE: [amibroker] How to simulate IB commission?
> 
>  
> 
> I just use .2% for all commissions. It overstates it a
> bit on the safe
> side.
> 
>  
> 
> --
> 
> Terry
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Mark H
> Sent: Thursday, April 06, 2006 17:23
> To: [email protected]
> Subject: [amibroker] How to simulate IB commission?
> 
>  
> 
> I just consolidated my accounts into an
> InteractiveBrokers account and
> would like to re-test my systems. I have no problem in
> Wealth-lab since
> I can use CommissionScript to describe the scheme. But in
> AmiBroker it
> is a bit difficult, and the portfolio commission table
> doesn't seem to
> help.
> 
> The scheme is : $0.005 * shares, min: $1.0,  max:
> 0.002*value. 
> 
> I think I can probably work around this by modify the
> SellPrice/BuyPrice
> to reflect the commission. But that's a bit messy and may
> have side
> effect.
> 
> Any Suggestion?
> 
>  
> 
> - Mark H.
> 
>  
> 
>  
> 
>  
> 
> 
> 
> 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 
> 
>  
> 
> *          Visit your group "amibroker
> <http://groups.yahoo.com/group/amibroker> " on the web.
>   
> 
> *          To unsubscribe from this group, send an email
> to:
>  [EMAIL PROTECTED]
>
<mailto:[EMAIL PROTECTED]>
> 
>   
> 
> *          Your use of Yahoo! Groups is subject to the
> Yahoo!
> <http://docs.yahoo.com/info/terms/>  Terms of Service. 
> 
>  
> 
>   _____  
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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:
    [EMAIL PROTECTED]

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



Reply via email to