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

[amibroker] Re: CBT Question


  • Date: Mon, 15 Feb 2010 16:53:33 -0000
  • From: "Pmxgs" <pmxgs@xxxxxxxxxx>
  • Subject: [amibroker] Re: CBT Question

PureBytes Links

Trading Reference Links



Hi,

I followed this suggestion which was to write sell=1 in the first phase of the
backtest and then assign zero to the possize property of the signal object to
avoid exiting trades (the condition to exit trades is only if profit from
current open positions is less than -8000 but not greater than 5000). (profit
>5000 is when profit target is hit)

If I assign zero to possize in case of a sell, does the backtester skip this
exit signal? Can I cycle through open positions list before cycling through signal list?
I don't get any response from the trace statement, so I'm probably have more mistakes in my code.


Here is my code to ilustrate what I'm trying to do. Any help ?

SetCustomBacktestProc("");

if (Status("action") == actionPortfolio) {

bo = GetBacktesterObject(); // Get backtester object

bo.PreProcess(); // Do pre-processing (always required)

for (i = 0; i < BarCount; i++) // Loop through all bars

profit=0;

{

for (trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos())

{ // Loop through all open positions

profit=profit+ trade.GetProfit() ;

_TRACE("profit at bar "+profit+"-"+i);

}

for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))

{ // Loop through all signals at this bar

if (sig.Isexit() && profit>-8000 && profit<5000) // If this signal is a long exit (ie. sell)

{

_TRACE("exit signal at bar "+i);

sig.possize=0;

}

} // End of for loop over signals at this bar

bo.ProcessTradeSignals(i); // Process trades at bar (always required)

} // End of for loop over bars

bo.PostProcess(); // Do post-processing (always required)

};

thanks


--- In amibroker@xxxxxxxxxxxxxxx, "Pmxgs" <pmxgs@xxx> wrote:
>
>
> Good idea. I hadn't hink of it that way.
> Let's see if I can code it correctly.
>
> thanks
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Mike" sfclimbers@ wrote:
> >
> > Medium level CBT allows to cancel buy signals by setting position size to 0. Assuming the same applies for sell signals (i.e. cancel the signal), you could try using "Sell = 1;" as your sell logic and then cancel the signals using medium CBT when not applicable.
> >
> > I'm not necessarily recommending the above. Just pointing out that it could potentially be done without low level CBT, if so desired.
> >
> > Mike
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "Pmxgs" <pmxgs@> wrote:
> > >
> > > Hi,
> > >
> > > I'm trying to create a system where all my entry rules can be defined without cbt, but the exit rule (which is to close all positions if the loss of all open positions is greater than 5% of equity).
> > >
> > > Since I have to use exit trade method of cbt, do I need do use the lowest level described in the help section of cbt?
> > >
> > >
> > >
> > > thanks
> > >
> >
>



__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





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

__,_._,___