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

[amibroker] Sample code for new backtestRegularRawMulti mode



PureBytes Links

Trading Reference Links

Hello,
 
Here is a sample of how to use new backtestRegularRawMulti backtester mode found in new AmiBroker 4.96.0
 
 
There are two new modes:
  • backtestRegularRaw:
    signal-based backtest, redundant (raw) signals are NOT removed, only one open position *per symbol* allowed (not counting scaling-in/out which is of course possible)

  • backtestRegularRawMulti - signal-based backtest, redundant (raw) signals are NOT removed, MULTIPLE positions per symbol will be open and reported separately if BUY/SHORT signal is "true" for more than one bar and there are free funds,  Sell/Cover exit all open positions on given symbol, Scale-In/Out work on all open positions of given symbol at once.
 
The sample below enters long trade on next day open when stock is making new 5-day high. If new high is made multiple times on same stock - multiple positions are open.
Exits are only done by 20% profit target and 15% trailing stop.
 
// trade on NEXT day open
SetTradeDelays( 1, 1, 1, 1 );
BuyPrice = Open;
SellPrice = Open;
// allow multiple pos on same symbol, reported separately
SetBacktestMode( backtestRegularRawMulti );

// 10% of equity in each position
SetPositionSize( 10, spsPercentOfEquity );

// max 10 positions in total
SetOption("MaxOpenPositions", 10 );

// buy each time a new 5-day highest high is reached
Buy = HHVBars( High, 5 ) == 0;

// exits only by means of stops
Sell = 0;

// 20% profit target stop
ApplyStop( stopTypeProfit, stopModePercent, 20, True );

// 15% trailing stop
ApplyStop( stopTypeTrailing, stopModePercent, 15
, True );

Best regards,
Tomasz Janeczko
amibroker.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 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





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___