Search code examples
trading

Amibroker: formula personalized per ticker


is it possible to 'personalize' a formula per each ticker ? In AFL, i would like to test 'different' buy condition for different ticker. For example:

Ticker AAPL, Rule A

Ticker MSFT, Rule B

Then, run AFL test each 5 minutes.

Concrete example:

ticker='AAPL';

Buy = Cross( MACD(), Signal() );

Alertif(..."MAIL", "Buy Apple beacuase Macd Cross");

ticker='MSFT' Buy = Close>EMA(Close,100);

Alertif(..."MAIL", "Buy Apple beacuase Macd Cross");

Etc.

Is it possible ?


Solution

  • if ( Name()=="AAPL" )
    {
    Buy = Cross( MACD(), Signal() );
    Alertif(..."MAIL", "Buy Apple beacuase Macd Cross");
    }
    
    if ( Name()=="MSFT" )
    {
    Buy = Close>EMA(Close,100);
    Alertif(..."MAIL", "Buy Apple beacuase Macd Cross");
    }