PureBytes Links
Trading Reference Links
|
Hi
Have you considered making slippage a part of the commision and
adjust it in the backtester commision settings beforehand, thus avoid
doing complicated calculations with the signal object of custom
backtester ?
Huanyan
--- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@xxx> wrote:
>
> Hello, hoping someone can help out with this code. Aron was kind
enough
> to post a version of some code that is meant to inject some slippage
> when using ApplyStop(). However, I can't seem to get it to work.
All I
> want it to do is reduce Long exits by 2 pips (I'm backtesting
Forex) and
> increase Short exits by 2 pips, when using ApplyStop.
>
> Here is the code. At present, it only ends up blanking out my
backtest
> report - no trades taken. Without the code, dozens or hundreds of
trades
> taken, depending on which system I test. As far as I can tell, this
code
> should work, but doesn't. Any input appreciated:
>
>
> SetCustomBacktestProc( "" );
> if ( Status( "action" ) == actionPortfolio )
> {
> TickSize = 0.0001; // Forex
> bo = GetBacktesterObject();
> bo.PreProcess();
> slipage = TickSize;
> spread = 2 * TickSize;
>
> for ( bar = 0; bar < BarCount; bar++ )
> {
> for ( sig = bo.GetFirstSignal(bar); sig; sig =
> bo.GetNextSignal(bar) )
> {
> symbol = sig.symbol;
> hi = Foreign(symbol, "H");
> lo = Foreign(symbol, "L");
>
> if ( sig.IsExit() )
> {
> if ( sig.isLong)
> {
> realexitprice = sig.price - slipage;
> if( realexitprice >= lo[bar] && realexitprice <=
> hi[bar])
> {
> sig.price = realexitprice;
> bo.ExitTrade(bar,sig.symbol,sig.Price); //
I'm not
> sure if it is needed
> }
> else
> sig.price = -1;
> }
> else
> {
> ealexitprice = sig.price + slipage;
> if (realexitPrice >= lo[bar]+ spread &&
realexitprice
> <= hi[bar]+spread)
> {
> sig.price = realexitprice;
> bo.ExitTrade(bar,sig.symbol,sig.Price); // I'm
not
> sure if it is needed
> }
> else
> sig.price = -1;
> }
>
> }
> }
>
> bo.ProcessTradeSignals( bar );
> }
> }
>
------------------------------------
**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
*********************
TO GET TECHNICAL 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/
|