Need Exploration for the below AFL

Hi Everyone ,

i have given the AFL below , its a simple EMA crossover . i have got the buy/sell signals from this forum itself.

And i have helpfull to all who helped me .

Just require a exploration code i.e., i need a alert output when ever a buy/sell signal is generated.

Thank you in advance

the AFL is as below :


_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );



Buy = Cross((EMA(Close,range1)),(EMA(Close,range2)));
Sell = Cross(EMA(Close,range2),(EMA(Close,range1)));
Short = Sell;
Cover = Buy;

// plot expanded average

Plot(EMA( Close,range1), "70min-ema", colorRed );
Plot(EMA( Close,range2), "1030min-ema", colorGreen );

// plot arrows
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );


perc=Param("text up-dn,",1,0.5,2,0.1);
dist = ((H+L)/1)/90* perc;
for( i = 0; i < BarCount; i++ )
if( Buy ) PlotText( "Buy\[email protected]" + C[ i ], i, L[ i ]-dist, colorWhite, colorGreen );
if( Sell ) PlotText( "Sell\[email protected]" + C[ i ], i, H[ i ]+dist, colorWhite, colorRed );


Last edited:
- trigger alerts Trading system toolbox
(AFL 2.1)

SYNTAX AlertIf( BOOLEAN_EXPRESSION, command, text, type = 0, flags = 1+2+4+8, lookback = 1 );
RETURNS nothing
FUNCTION Triggers alert action if BOOLEAN_EXPRESSION is true.
1. BOOLEAN_EXPRESSION is the expression that if evaluates to True (non zero value) triggers the alert. If it evaluates to False (zero value) no alert is triggered. Please note that only lookback most recent bars are considered.

2. The command string defines the action taken when alert is triggered. If it is empty the alert text is simply displayed in the Alert output window (Window->Alert Output). Other supported values of command string are:
SOUND the-path-to-the-WAV-file
EXEC the-path-to-the-file-or-URL

SOUND command plays the WAV file once.
EMAIL command sends the e-mail to the account defined in the settings (Tools->Preferences->E-mail). The format of the e-mail is as follows: Subject: Alert type_name (type) Ticker on Date/Time
Body: text
EXEC command launches external application or file or URL specified after EXEC command. are attached after file name and text is attached at the end

3. Text defines the text that will be printed in the output window or sent via e-mail or added as argument to the application specified by EXEC command

4. Type defines type of the alert. Pre-defined types are 0 - default, 1 - buy, 2 - sell, 3 - short, 4- cover. YOu may specify higher values and they will get name "other"

5. Flags control behaviour of AlertIF function. This field is a combination (sum) of the following values:
( 1 - display text in the output window, 2 - make a beep (via computer speaker), 4 - don't display repeated alerts having the same type, 8 - don't display repeated alerts having the same date/time) By default all these options are turned ON.

6. lookback parameter controls how many recent bars are checked

EXAMPLE Buy = Cross( MACD(), Signal() );
Sell = Cross( Signal(), MACD() );
Short = Sell;
Cover = Buy;
AlertIF( Buy, "EMAIL", "A sample alert on "+FullName(), 1 );
AlertIF( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
AlertIF( Short, "EXEC Calc.exe", "Launching external application", 3 );
AlertIF( Cover, "", "Simple text alert", 4 );

Thank you Shurti and Manoj ..

But i a new comer to coding in Amibroker.. i have little idea.. but not fully

If u can tell me the code it would be very helpful ...

But i tried myself and tried a few codes. Check it out ,



Buy = Cross((EMA(Close,range1)),(EMA(Close,range2)));
Sell = Cross(EMA(Close,range2),(EMA(Close,range1)));

Filter=Cross(EMA(C,14),EMA(C,206)) ;



In the above exploration code. The stocks are scanned for BUy/SELL signals...

But it is not displayed in the Alert Output window...

Plz help me out .. how to get the scanned stocks in the Alert output window..

Thank you in advance.

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Are you a day trader?