PureBytes Links
Trading Reference Links
|
I think you can do this:
SetTradeDelays(1,1,1,1);
slippage = ...
SellPrice = Open - slippage;
CoverPrice = Open + slippage;
However, this may not reflect the way you will actually trade. The
backtested system has a 1 bar trade delay. How are you planning to
trade this in real life? If the profit target or stop level is
detected in real-time will you exit the trade immediately or wait
until the next bar?
-Steve
--- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@xxx> wrote:
>
> Hi. I am hoping anyone out there can check this code and perhaps give me
> some pointers on how to do the actual scaling up and down of the exit
> prices?
>
> To mimic a more realistic backtesting model for trading Forex, I want to
> scale the backtester's exit prices down 2 pips if a Sell and up 2 pips
> if a Cover. My actual trade system has a 1-bar trade delay so not sure
> how that affects the below code. I added a generic trade system to the
> below code for the sake of simplicity.
>
> Is this the correct approach? Or do I need to add some custom metrics?
> I'm not too sure if this approach is the right way. And I'm still
> missing the meat and potatoes - in the two "ADD CODE HERE" sections:
>
> // Custom Backtester Code to add Slippage to Forex trades
> //
> // We Sell and Cover on Open.
> // But we want actual Sell prices to be slipped down by 2 pips and
> // actual Cover prices to be slipped up by 2 pips.
>
> // First we need to enable custom backtest procedure AND
> // tell AmiBroker to use current formula
>
> SetCustomBacktestProc("");
>
> // Now custom-backtest procedure follows
>
> if( Status("action") == actionPortfolio )
> {
> bo = GetBacktesterObject();
>
> bo.Backtest(1); // run default backtest procedure
>
> // iterate through closed trades first
>
> for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
> {
> if( sig.IsLong() AND sig.IsExit() ) //check if the signal is
> a Sell of a Long position
> {
> // ADD CODE HERE: NEED TO REDUCE THE SELL EXIT PRICE BY
> 0.0002
> }
>
> if( NOT sig.IsLong() AND sig.IsExit() ) //check if the
signal is
> a Cover of a Short position
> {
> // ADD CODE HERE: NEED TO INCREASE THE COVER EXIT PRICE BY
> 0.0002
> }
> }
> }
>
> // your trading system here
>
> fast = Optimize( "fast", 12, 5, 20, 1 );
> slow = Optimize( "slow", 26, 10, 25, 1 );
> Buy=Cross( MACD( fast,slow ),Signal( fast,slow ) );
> Sell=Cross( Signal( fast,slow ),MACD( fast,slow ) );
> BuyPrice = SellPrice = ShortPrice = CoverPrice = Open;
>
------------------------------------
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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
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/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|