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 [email protected], "Pmxgs" <pm...@...> wrote:
>
> 
>  Good idea. I hadn't hink of it that way.
>  Let's see if I can code it correctly.
> 
>  thanks 
> 
> --- In [email protected], "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 [email protected], "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
> > >
> >
>


Reply via email to