How to get sound alerts in amibroker?

#1
With all the info ive gathered, I have been tinkering with the code to get sound alerts. All the time it falls short. Sometimes it shouts even when the candle is forming, or doesnt alert all the time or alerts only for a few instruments. I have zero coding knowledge. I have following requirements.

1. Get sound alerts like to say what i define in the code. So whenever a buy signal occurs it should say "Buy Now" or whatever is put in the code. Would also be better if it also says the ticker name. The most important thing is for the sound alert to come after the closing of the candle.

2. Now the same alert system if i put a code in AutoScan mode in analysis window.

I attach a sample code below. Do modify.

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
_N( Title = Title +"\n" + _DEFAULT_NAME() );

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

Buy = Close > Open
AND MACD( 12, 26 ) > MACD( 6, 13 );

Sell = Close < Open
AND MACD( 12, 26 ) < MACD( 6, 13 );

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue,0,Low,Offset=-15);

PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),coloryellow,0,Low,Offset=-50);
 

amsin21

Well-Known Member
#2
Already posted in TJ.... try this

function SayNotTooOften( text, Minperiod )
{
elapsed=GetPerformanceCounter()/1000;
Lastelapsed = Nz( StaticVarGet("lastsaytime") );

if( elapsed - Lastelapsed > Minperiod )
{
StaticVarSet("lastsaytime", elapsed );
Say( text );
}
}

.
.
.
Buy = Close > Open AND MACD( 12, 26 ) > MACD( 6, 13 );

Sell = Close < Open AND MACD( 12, 26 ) < MACD( 6, 13 );

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBl ue,0,Low,Offset=-15);

PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),coloryellow,0,Low,Offset=-50);

if(LastValue(Buy)) SayNotTooOften(Name()+Interval(2)+"Buy triggered",180);
if(LastValue(Sell)) SayNotTooOften1(Name()+Interval(2)+"Sell triggered",180);
 
#3
Already posted in TJ.... try this
1. Have used this code before but to no avail. This acts weird. Yesterday it was giving alerts with still 12-15 seconds to go and today it alerts with still another 45 sec left. Doesnt solve.

2. Also this alerts only for the chart opened. What if i want alerts for a group of scrips.

3. Also do you know DIY scanners for non geeks. The code wizard of Ami is pretty handy.The analysis window of Ami is not that great for me. Whenever its put on AutoScan mode, after scanning itll not show the recent signals first. The list begins with the signals of 915 am.

Appreciate your help. I m kind of desperate for this. Thanks. Do use this sample code in realtime to check.
Code:
_SECTION_BEGIN("Formula 2");
SetChartOptions(0,chartShowArrows|chartShowDates); 
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 
_N( Title = Title +"\n" + _DEFAULT_NAME() ); 

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 


function SayNotTooOften( text, Minperiod ) 
{ 
elapsed=GetPerformanceCounter()/1000; 
Lastelapsed = Nz( StaticVarGet("lastsaytime") ); 

if( elapsed - Lastelapsed > Minperiod ) 
{ 
StaticVarSet("lastsaytime", elapsed ); 
Say( text ); 
} 
}

Buy = 	Close > Open;
	

Sell = Close < Open;


PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue,0,Low,Offset=-15);

PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),coloryellow,0,Low,Offset=-50); 

if(LastValue(Buy)) SayNotTooOften(Name()+Interval(2)+"Buy triggered",60);
if(LastValue(Sell)) SayNotTooOften(Name()+Interval(2)+"Sell triggered",60);
_SECTION_END();
 

amsin21

Well-Known Member
#4
1. Have used this code before but to no avail. This acts weird. Yesterday it was giving alerts with still 12-15 seconds to go and today it alerts with still another 45 sec left. Doesnt solve.

Only on trigger from your condition, alert will be generated. So the alert generated should be a valid one. May be the delay because of hardware delay. I have also noticed the same on and off. For me that seconds really don't matter, as I just consider the audio alert just to look the charts for possible entries.

2. Also this alerts only for the chart opened. What if i want alerts for a group of scrips.

Obviously for the trigger to happen, AFL should be active. For AFL to be active, chart should be opened.

3. Also do you know DIY scanners for non geeks. The code wizard of Ami is pretty handy.The analysis window of Ami is not that great for me. Whenever its put on AutoScan mode, after scanning itll not show the recent signals first. The list begins with the signals of 915 am.

No idea.
 

Similar threads