Hi,

I'm not familiar with the FindSignal method that you describe. But, 
it sounds like you could get the same thing by looping through the 
list of signals using GetFirstSignal(i) and GetNextSignal(i) 
http://www.amibroker.com/guide/a_custombacktest.html

Mike

--- In [email protected], "tipequity" <[EMAIL PROTECTED]> wrote:
>
> The following CBT code is supposed to sell a long position after 
nth 
> bar if I don't have a buy signal on the nth bar. The logic for the 
> code is as follows:
> 
> 1. loop thru open position list
> 2. if a positions has been open for nbar then check the buy list 
> 3. if the symbols exits in the buy list do nothing else sell the 
> position.
> 
> For some reason that I can not figure out, the new function 
> FindSignal always return a null value. Can anybody provide some 
> insight or an alternative solution? TIA
> 
> 
> for ( pos = bo.GetFirstOpenPos(); pos; pos = bo.GetNextOpenPos() )
> {
>       if ( pos.BarsInTrade >= Nbar ) 
>       {
>               _TRACE("i= " + i + " Date: " + dtstr + " Symbol: :" + 
> pos.Symbol + " BarsinTrade: " +  pos.BarsInTrade + " Max Holding 
> Period");
>               if ( Sig = bo.FindSignal( i, pos.Symbol, 1 ) )
>               {
>                       // ignore sell signal if we also have a buy 
> signal
>                       _TRACE("i= " + i + " Date: " + dtstr + " 
> Symbol: :" + pos.Symbol + " BarsinTrade: " +  pos.BarsInTrade + " 
> ignore sell signal, we have Buy Signal, don't sell: " + sig);
>               }
>               else 
>               {
>                       NextDayOprice = pos.getprice(i,"O");
>                       bo.ExitTrade( i, pos.symbol, NextDayOprice, 
> 5);
>                       _TRACE("i= " + i + " Date: " + dtstr + " 
> Symbol: :" + pos.Symbol + " BarsinTrade: " +  pos.BarsInTrade + " 
We 
> DONT have Buy Signal: " + sig );
>               }
>       }
> }
>


Reply via email to