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

Fwd: [amibroker] How can a Low level backtest access AFL function values ??



PureBytes Links

Trading Reference Links



Note: forwarded message attached.


Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. __._,_.___

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




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

__,_._,___
--- Begin Message ---
  • To: amibroker@xxxxxxxxxxxxxxx
  • Subject: [amibroker] How can a Low level backtest access AFL function values ??
  • From: "joelamibroker" <joelamibroker@xxxxxxxxxxxx>
  • Date: Tue, 27 Nov 2007 04:03:08 -0000
  • Authentication-results: mta431.mail.mud.yahoo.com from=yahoogroups.com; domainkeys=pass (ok)

Hello,

How can you access AFL function values that work on price arrays in a
low level backtest??

I am attempting to handle multiple signals using Custom Backtester.
In version 4.76.0 Tomasz introduced the "Handle" property.

In this simple example I want to use "Handle" to exit if share has
dropped 2xATR(30) from BuyPrice.
(note: 2xATR(30) is calculated on the 'Buy' day)

The middle line of code is obviously incorrect, but HOW should it be
written?

for( pos = bo.GetFirstOpenPos(); pos; pos = bo.GetNextOpenPos() )
{
if(pos.GetPrice(bar,"C") < pos.GetEntryValue() -
2*ATR(30).[bar-pos.BarsInTrade])
bo.ExitTrade(......);
}

Any ideas on how this can be done would be appreciated.

Complete code is listed below:

/* Backtest is carried out on multiple symbols*/

Buy = Cross(C,Ref(HHV(H,20),-1);
BuyPrice = Open;
Sell = 0;
SellPrice = 0;

if( Status("action") == actionPortfolio )
{
// actual backtest routine(low-level)
bo = GetBacktesterObject();
bo.PreProcess();

for( i = 1; i < BarCount; i++ )
{
// first update backtest stats and handle stops
bo.UpdateStats( i, 0 );

for( sig = bo.GetFirstSignal(i);sig; sig = bo.GetNextSignal(i) )
{
if (sig.IsLong() AND sig.Price != -1)
{
bo.RawTextOutput("Bar " + i + " Symbol: " + sig.Symbol);
bo.EnterTrade(i, sig.Symbol, True, sig.Price,-10);
for(pos=bo.GetFirstOpenPos();pos;pos = bo.GetNextOpenPos() )
{
bo.RawTextOutput("Open Pos Found For: " + pos.Symbol);
/* --- Now Process Exit ---*/
/* --- This won't work ---*/
/* --- Have we closed 2xATR(30) below entry price? */
if(pos.GetPrice(i,"C") < pos.GetEntryValue() -
2*ATR(30).[i-pos.BarsInTrade])
bo.ExitTrade( i+1, OpenPos.Handle, OpenPos.GetPrice( i+1, "O" ) );

}

}
bo.UpdateStats( i, 2 );
}
bo.PostProcess();
}


--- End Message ---