>From Amibroker Knowledge Base
Larry

September 29, 2006
How to set individual trading rules for symbols in the same backtest
The following code shows how to use separate trading rules for 
several symbols included in the same backtest. 


// default trading rules if the symbol is not specified below:
Buy = Cross( MA( Close, 20), MA( Close, 50) );
Sell = Cross( MA( Close, 50), MA( Close, 20) );

// individual trading rules for selected symbols 
// that will overwrite the above default rules 
// if particular symbol is detected

// system for MSFT
if( Name() == "MSFT" )
{
 Buy = Cross( MA( Close, 50), MA( Close, 100) );
 Sell = Cross( MA( Close, 100), MA( Close, 50) );
}

// system for IBM
if( Name() == "IBM" )
{
 Buy = Cross( MACD(), Signal() );
 Sell = Cross( Signal(), MACD() );
}

// system for NVDA
if( Name() == "NVDA" )
{
 Buy = Cross( RSI(), 30);
 Sell = 0;
 ApplyStop( stopTypeNBar, stopModeBars, 10);
} 


Note that different per-symbol stops (ApplyStop) are possible only in 
regular (non-rotational) backtest.

 Filed by support at 6:55 am under AFL, Systems



--- In [email protected], "triangle702000" <[EMAIL PROTECTED]> wrote:
>
>  I'm wondering if there is a way to assign a moving average only to 
one 
> specific stock and not to every one in the database.For example,if 
I 
> have a 50 day and a 200 day MA applied to all stocks,but I find 
that 
> for "XYZ" a 59 day MA follows the trend a bit better,can I apply a 
59 
> day MA only to XYZ while keeping the 50 and 200 day for the rest?
> 
> I know I can simply add the 59 day,but I'd rather not have it on 
all 
> the other charts if it's possible.Thanks.  -jim
>


Reply via email to