PureBytes Links
Trading Reference Links
|
Hello,
> My hypothesis is that the root of the stop problem is that ApplyStops
> itself uses current bar High (when in Long position) which can lead to
> situations where that is indeed future information (e.g., Low of day
> triggered the stop but the Low happened hours before the High of the
> day happened and thus it should not have been triggered).
This topic appears here over and over again, so once again I explain:
usign EOD data you have NO WAY to know whenever High occurred earlier
than Low or vice versa.
If you use EOD data you need to make some assumption. And AmiBroker takes
WORST case assumption (i.e. if low is below trail stop it exits the trade).
You end up with less profit but it safer to generate backtest showing smaller
profits than assuming "good luck".
This is safer than assuming that low happens before high (very risky)
Also your code uses BarsSince(Buy) to calculate High since entry of long trade
which is incorrect if Buy formula generates repeated signals.
Correct way is to use looping as explained several times on this list
and also in the user's guide
See the very end of
http://www.amibroker.com/guide/whatsnew.html
* a sample low-level implementation of Profit-target stop in AFL: */
Buy = Cross( MACD(), Signal() );
priceatbuy=0;
for( i = 0; i < BarCount; i++ )
{
if( priceatbuy == 0 && Buy[ i ] )
priceatbuy = BuyPrice[ i ];
if( priceatbuy > 0 && SellPrice[ i ] > 1.1 * priceatbuy )
{
Sell[ i ] = 1;
SellPrice[ i ] = 1.1 * priceatbuy;
priceatbuy = 0;
}
else
Sell[ i ] = 0;
}
/* sample EMA rainbow */
Plot( Close, "Price", colorBlack, styleCandle );
for( Range = 15; Range < 100; Range++ )
Plot( EMA( Close, Range ), "MA"+WriteVal(Range,0), colorRose + Range % 8, styleNoLabel );
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "JD Fagan" <jd.fagan@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, October 25, 2005 2:33 AM
Subject: [amibroker] problems with AmiBroker built-in stop capabilities
> Hi,
>
> I think there are some slight but serious problems with how AB deals
> with implementing built-in stops (at least for trailing mode type of
> stops) via the ApplyStops function when used within the context of
> backtesting and/or visually charting the buy/sell arrows on a chart.
>
> I've included sample code (at bottom in "Code Below" section) to help
------------------------ Yahoo! Groups Sponsor --------------------~-->
Try Online Currency Trading with GFT. Free 50K Demo. Trade
24 Hours. Commission-Free.
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~->
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:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|