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

[amibroker] Re: CBT Question


  • Date: Mon, 15 Feb 2010 16:41:08 -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 0 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 greater than    -8000 but less 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?
I don't get any response from the trace statement, so I'm doing several things wrong. 


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) //skip exits	      {
                _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/

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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/