How to add sound when price is reaching to particular price?

Dear all,

I need a sound/beep when price reaches to particular line.

my code is a follows.

_SECTION_BEGIN("draw me");
lin1 = Param("Number 1",61 , 7, 10000, 10);
Plot(lin1 ,"",ParamColor("line1 color",colorWhite),styleLine,1,1) ;

lin2 = Param("Number 2",101, 7, 10000, 10);
Plot(lin2 ,"",ParamColor("line2 color",colorWhite),styleLine,1,1) ;

lin3 = Param("Number 3",141, 7, 10000, 10);
Plot(lin3 ,"",ParamColor("line3 color",colorYellow),styleLine,1,1) ;

lin4 = Param("Number 4",155, 7, 10000, 10);
Plot(lin4 ,"",ParamColor("line4 color",colorWhite),styleLine,1,1) ;

_SECTION_END();

i not a coder i have a AFL which is plotting lines as per given number in RT data feed. I need beep sound too.

plese suggest.

Prakash Modak
prakash.modak65@gmail.com

https://amibroker.com/guide/afl/playsound.html

Here is a list of all functions you can call from within AFL

https://amibroker.com/guide/a_catfunref.html

True but i can not code , i need on RT data i.e. on 15M Time Frame.

I am just user of Amibroker cant code AFL.

If its possible please send me AFL

Thanks and Regards,
prakash.modak65@gmail.com

AFL Function Reference - ALERTIF (amibroker.com)
This is a better or managed way of using Alerts over direct PlaySound()
Just fyi

1 Like

_SECTION_BEGIN("Price");
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 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_END();

_SECTION_BEGIN("draw me");
Sound = ParamStr("Sound","C:/Windows/Media/Ring01.wav");

lin1 = Param("higher tgt",141 , 7, 10000, 10);
Plot(lin1 ,"",ParamColor("line1 color",colorRed),styleLine,1,1) ;

lin2 = Param("lower trgt",101, 7, 10000, 10);
Plot(lin2 ,"",ParamColor("line2 color",colorGreen),styleLine,1,1) ;

if((C[0]>lin1 AND C[0]<lin1+1) OR (C[0]<lin2 AND C[0]>lin2-1))
{PlaySound(Sound);}

_SECTION_END();

//need price alert on reching above all prices. just beep / sound on reachin SP at this particular level of PRICE LINES

but here i can not add more number of lines , i need 10 more lines, for e.g. given only two numbers 101 and 141 but need more 10 nember /lines.

When i start trading price can be any where in between only it should give sound when it reaches near by line. actually there no need to identify targets. i can set target manually.

Simply when price hit the nearby line it should give sound. "draw_me " drawn the line but its not giving me beep when price reached there.

reason is there is no need to check the screen all time only sound will alert me.

i hope so you have understood my need.

Step 1. Learn to code in AFL.
Step 2. Write your sound alert.

Coming to a programming forum, asking for help and saying that you cannot and do not want to learn to program is like a kid going to swimming school, asking to be given the knowledge to swim but saying they cannot swim and do not want to learn.

G'luck, you'll definitely need it.

1 Like

Recommended reading is as always Tutorial:

https://www.amibroker.com/guide/h_alerts.html

https://www.amibroker.com/guide/h_understandafl.html

In addition to AlertIF there are direct functions to play the sound as others pointed out. Trouble is that you are making several mistakes in your code caused by the fact that you did NOT read the docs. You are referring to C[0] but you need to read the tutorial, to understand that C[0] is FIRST (i.e. OLDEST) quote, not most recent one. Also you should be using built-in array functions that are easier to use than anything else.

For example

lin2 = Param("lower trgt",101, 7, 10000, 10);

// to detect cross use... Cross()
// to get last value use ... LastValue()

Crossed_Above_Lin2 = LastValue( Cross( Close, Lin2 ) );
if( Crossed_Above_Lin2  ) PlaySound("sound.wav");

// was this that difficult??

Alternative solution with AlertIF (it does not require using LastValue and has internal logic preventing repetitions)

AlertIF( Cross( Close, Lin2 ), 
            "SOUND C:\\Windows\\Media\\Ding.wav", 
            "Audio alert", 1 );

Sir,

Thanks for G'luck.

What you are saying is absolutely true but I am a trader and using Amibroker only for trading point of view not creating AFL based on any indicator like RSI, MACD etc..

I am just using only price action , no any indicators not even EMA.

I have trading platform (Trade Tiger from Sharekhan) which gives me facility to assign price_alert when a particular price appears on chart , but for every option strike price i have to do the same repetitive work to assign price this kills my precious time of trading being price is very volatile.

This repetitive work can be handle by simple logic (because price pointers are fixed or can be change in AFL) in Amibroker.

Amibroker also gives facility to plot Horizontal line with color & style etc but sound is missing, and that is also for a particular script not as a template to use for any strike price.

That what I have observed and this can done only in AFL.

But Thanks for your valuable time & guidance.

Regards,

Prakash Modak
India
prakash.modak65@gmail.com