PureBytes Links
Trading Reference Links
|
Tomasz, can you help me with this?
Thanks
Kam
--- In amibroker@xxxxxxxxxxxxxxx, "tipequity" <l3456@xxx> wrote:
>
> Thanks Dingo, This doesn't work. Looking at FindOpenPos
descreiption
> it says that it would return values of 1 or null. Initially I had
> writtern the code as follows (Sig.IsExit() AND OpenPos AND
> OpenPos.BarsInTrade >= 2). When I couldn't get it to work, I posted
> my question on this board.
>
> SetBacktestMode( backtestRegularRaw );
> SetCustomBacktestProc("");
> if( Status("action") == actionPortfolio )
> {
> bo = GetBacktesterObject();
> bo.PreProcess();
> for( i = 0; i < BarCount; i++ )
> {
> for( sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
> {
> OpenPos = bo.FindOpenPos( sig.Symbol );
> if( Sig.IsExit() AND OpenPos AND OpenPos.BarsInTrade >= 2)
>
> {
> bo.ExitTrade( i, OpenPos.symbol, sig.Price, 1);
> }
> }
> bo.HandleStops(i);
> bo.UpdateStats(i,1);
> bo.UpdateStats(i,2);
> }
> bo.PostProcess();
> }
>
> --- In amibroker@xxxxxxxxxxxxxxx, "dingo" <dingo@> wrote:
> >
> > I haven't used it either but you need to experiment with
> > OpenPos.BarsInTrade:
> >
> > if( Sig.IsExit() AND OpenPos)
> > {
> > if( OpenPos.BarsInTrade >= 4 )
> > {
> > bo.ExitTrade( i, OpenPos.symbol, sig.Price, 1);
> > }
> > }
> >
> > I don't think this is going to do the trick as you are getting to
> the
> > opentrade via the signal object.. which you want to be 2 days
> old... but
> > maybe putting the signal into state mode instead of impulse mode
> will do it
> > for you.
> >
> > d
> >
> > > -----Original Message-----
> > > From: amibroker@xxxxxxxxxxxxxxx
> > > [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of tipequity
> > > Sent: Wednesday, October 10, 2007 9:51 PM
> > > To: amibroker@xxxxxxxxxxxxxxx
> > > Subject: [amibroker] Re: CBT Help
> > >
> > > Dingo, I did look at that but I could not figure out how to
call
> it.
> > > Would mind detailing how I can use it.
> > >
> > > Thanks
> > > Kam
> > > --- In amibroker@xxxxxxxxxxxxxxx, "dingo" <dingo@> wrote:
> > > >
> > > > Look at the BarsInTrade property of the trade object
> > > >
> > > > d
> > > >
> > > > > -----Original Message-----
> > > > > From: amibroker@xxxxxxxxxxxxxxx
> > > > > [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of tipequity
> > > > > Sent: Wednesday, October 10, 2007 9:33 PM
> > > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > > Subject: [amibroker] CBT Help
> > > > >
> > > > > I have written the following CBT code to exit open long
> position
> > > on
> > > > > sell siganls. Now I want to add another cluase that the
> position
> > > must
> > > > > have been open for at least two bars. SetOption
> ("HoldMinBars",2 )
> > > > > doesn't work for me because it starts counting from the
last
> buy
> > > > > signal. So to achive my objective I need to call
BarsInTrade
> > > > > property. What I don't know how do is access this property
of
> the
> > > > > trade method inside a signal loop. Your help would be much
> > > > > appreciated.
> > > > >
> > > > > TIA
> > > > > Kam
> > > > >
> > > > > SetBacktestMode( backtestRegularRaw );
> > > > > SetCustomBacktestProc("");
> > > > > if( Status("action") == actionPortfolio )
> > > > > {
> > > > > bo = GetBacktesterObject();
> > > > > bo.PreProcess();
> > > > > for( i = 0; i < BarCount; i++ )
> > > > > {
> > > > > for( sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal
> (i))
> > > > > {
> > > > > OpenPos = bo.FindOpenPos( sig.Symbol );
> > > > > if( Sig.IsExit() AND OpenPos)
> > > > > {
> > > > > bo.ExitTrade( i, OpenPos.symbol, sig.Price, 1);
> > > > > }
> > > > > }
> > > > > bo.HandleStops(i);
> > > > > bo.UpdateStats(i,1);
> > > > > bo.UpdateStats(i,2);
> > > > > }
> > > > > 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
> > >
> > >
> > >
> > >
> >
>
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/
|