Hi i want a sound or voice alert for this afl plz help me

_SECTION_BEGIN("MACD Exploration");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
Z=Param("zig",1,0,10,0.1);


Cond1 = Cross(MACD(r1,r2),Signal(r1,r2,r3));

Cond3 = Zig(C,z)>Ref(Zig(C,z),-4);
Buy = Cond1 AND Cond3;

Cond4 = Cross(Signal(r1,r2,r3),MACD(r1,r2));

Cond6 = Zig(C,z)<Ref(Zig(C,z),-4);
Sell = Cond4 AND Cond6;
Trigger = WriteIf(Buy, "Buy", "") + WriteIf(Sell, "Sell", "");

_N(Title = StrFormat("{{NAME}} {{DATE}} {{INTERVAL}}: O=%1.2f, H=%1.2f, L=%1.2f, C=%1.2f, V=%1.0f\n{{VALUES}}", O, H, L, C, V));

BG = IIf(Buy, colorPaleGreen, IIf(Sell, colorRose, colorDefault));
FG = IIf(Buy, colorDarkGreen, IIf(Sell, colorDarkRed, colorDefault));

if(Status("action") == actionIndicator)
{

PlotShapes(IIf(Buy, shapeStar, shapeNone),colorBrightGreen, 0,L, Offset=-0);
PlotShapes(IIf(Buy, shapeHollowSquare, shapeNone),colorYellow, 0,L, Offset=-0);
 
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorPink, 0,H, Offset=-01);
PlotShapes(IIf(Sell, shapeHollowSquare, shapeNone),colorRed, 0,H, Offset=-01);
}

//------------------------------------------------------------------------------------------------
if(Status("action") == actionExplore)

Filter = Buy OR Sell;
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol", 77, FG, BG, 120);
AddColumn(DateTime(), "Date", formatDateTime, FG, BG, 100);
AddColumn(TimeNum() ,"Time",1);
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn(V, "Volume");
AddColumn(Ref(V,-1),"P-Vol");
AddColumn(V/Ref(V,-1)*100,"Increase in Vol");
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );

shape = Buy * shapeUpTriangle + Sell * shapeDownTriangle;


PlotShapes( shape, IIf( Buy, colorYellow, colorOrange ), 0, IIf( Buy, Low, High ) );

GraphXSpace = 7;

GraphXSpace = 7; 
_SECTION_END();

You can find many example codes on the forum --> https://forum.amibroker.com/search?q=alert

For instance:

etc.

Using formula-based alerts:
https://www.amibroker.com/guide/h_alerts.html
https://www.amibroker.com/guide/afl/alertif.html
https://www.amibroker.com/guide/afl/playsound.html
https://www.amibroker.com/guide/afl/say.html

2 Likes

Thank you very for your reply but i am new to coding please help me to change it as per above code

Yes, i got it Thanks for your help