PureBytes Links
Trading Reference Links
|
Hello,
(Position) pos is a pointer to COM object, technically the name is IDispatch.
It can be used in if() statement too because in AFL non-null pointer is "true"
and null pointer (empty) has logical value of false.
IsEntry is -1 because in COM the true value is -1. It does not really matter
as long as it is different than zero. In AFL every value DIFFERENT than
zero (or null) is treated as TRUE, zero in logical expression means "false".
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "tipequity" <l3456@xxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, May 15, 2008 8:06 AM
Subject: [amibroker] (unknown)
> When I run the CBT code listed below the trace statement return
> something like the following:
>
> [864] Can Enter bar = LUK Pos: {EMPTY} isEntry: -1
> [864] Pos already exists LUK Pos: <IDispatch> isEntry: -1
> [864] Can Enter bar = LUK Pos: {EMPTY} isEntry: -1
>
> Why is it that "pos" returns null and isEntry returns -1. Also I can
> not explain "pos" returning <IDispatch>. I thought these variables
> were supposed to return 1 and 0 for true and false. Can anybody
> explain? TIA
>
>
>
>
> SetBacktestMode( backtestRegularRaw2 );
> SetCustomBacktestProc("");
> MaxBuys = 3;
> if ( Status( "action" ) == actionPortfolio )
> {
> bo = GetBacktesterObject();
> bo.PreProcess();
> for ( i = 0; i < BarCount; i++ )
> {
> dtstr = DateTimeToStr( dt[ i ] );
> cntBuys = 0;
> for ( sig = bo.GetFirstSignal( i ); sig; sig =
> bo.GetNextSignal( i ) )
> {
> if ( sig.IsEntry() )
> {
> CanEnter = False;
> if ( CntBuys <= MaxBuys )
> {
> pos = bo.FindOpenPos(
> sig.Symbol );
> if ( pos )
> {
> _TRACE( "Pos already exists "
> + sig.Symbol + " Pos: " + Pos + " isEntry: " + sig.IsEntry());
> }
> else
> {
> CanEnter = True;
> CntBuys++;
> _TRACE( "Can Enter bar = " +
> sig.Symbol + " Pos: " + Pos + " isEntry: " + sig.IsEntry());
> }
> }
> if ( ! CanEnter )
> sig.Price = -1;
> }
> if ( sig.IsExit() )
> break;
> }
> // now check all open positions and find matching signals
> for ( pos = bo.GetFirstOpenPos(); pos; pos =
> bo.GetNextOpenPos() )
> {
> if ( ( sig = bo.FindSignal( i, pos.Symbol,
> 2 ) ) ) // look for exit position matching given open pos
> {
> if ( pos.BarsInTrade < 2 )
> sig.Price = -1; // ignore
> sell signal if trade is too young
> // _TRACE("i= " + i + " Date: "
> + dtstr + " BarsinTrade: " + pos.BarsInTrade);
> }
> }
> bo.ProcessTradeSignals( i );
> }
> bo.PostProcess();
> }
>
>
>
> ------------------------------------
>
> 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
>
>
>
------------------------------------
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/
|