how to add buy sell signal sound

casoni

Well-Known Member
#2
Hello ,
Add this below your Buy/Short/Sell/Cover condition

barcomplete = BarIndex() < LastValue(BarIndex());
//AlertIf( barcomplete AND Buy, "", "NMA-Buy ", 1 ); // this will dispaly in Alert output
AlertIf( barcomplete AND Buy, "SOUND C:\\Windows\\Media\\notify.wav", "Audio alert", 1 );// sound
//AlertIf( barcomplete AND Sell, "", "NMA-Sell", 2 );
AlertIf( barcomplete AND Sell, "SOUND C:\\Windows\\Media\\chimes.wav", "Audio alert", 2 );
//AlertIf( barcomplete AND Short, "", "NMA-Short", 3 );
AlertIf( barcomplete AND Short, "SOUND C:\\Windows\\Media\\chord.wav", "Audio alert", 3 );
//AlertIf( barcomplete AND Cover, "", "NMA-Cover", 4 );
AlertIf( barcomplete AND Cover, "SOUND C:\\Windows\\Media\\ringout.wav", "Audio alert", 4 );

hope this helps
thank you
 

kumudhan

Well-Known Member
#5
hello casoni, tell me can i add sound effect in amibroker when my price reach to my target price.

For eg. I purchase Bank nifty @ 10500 and my target is 10650 and stoploss is 10475.

I want to set alert if price reach to 10650 and second alert if price reach to my stop loss price 10475.


thank you in advance.
 
#6
Post your code here ..

this my AFL code...




SetChartBkGradientFill( ParamColor( "TopColor", ColorRGB( 217, 197, 137 ) ), ParamColor( "BottomColor", ColorRGB( 254, 244, 224 ) ) );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

_SECTION_BEGIN("BHS");
SetBarsRequired(200,0);

GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k = Optimize("K",Param("K",1,0.25,5,0.25),0.25,5,0.25);
Per= Optimize("atr",Param("atr",4,3,20,1),3,20,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorGreen, styleCandle | styleNoLabel );
j=Haclose;


//=========================Indicator======================
f=ATR(14);
rfsctor = WMA(H-L, Per);
revers = k * rfsctor;
Trend = 1;
NW[0] = 0;
for(i = 1; i < BarCount; i++)
{
if(Trend[i-1] == 1)
{
if(j < NW[i-1])
{
Trend = -1;
NW = j + Revers;
}
else
{
Trend = 1;
if((j - Revers) > NW[i-1])
{
NW = j - Revers;
}
else
{
NW = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j > NW[i-1])
{
Trend = 1;
NW = j - Revers;
}
else
{
Trend = -1;
if((j + Revers) < NW[i-1])
{
NW = j + Revers;
}
else
{
NW = NW[i-1];
}
}
}
}

//===============system================

_SECTION_BEGIN("ema5,13sound");
x = EMA(Close,5);
y = EMA(Close,13);
Plot(EMA(Close,5),"",colorBlue,styleLine, styleThick);
Plot(EMA(Close,13),"",colorRed,styleLine, styleThick);
XR=(EMA(Close,5) * (2 / 6 - 1) - EMA(Close,13) * (2 / 11 - 1)) / (2 / 6 - 2 / 11);


Buy=Cross(j,nw);
Cover=Cross(j,nw);
Sell=Cross(nw,j);
Short=Cross(nw,j);
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
_SECTION_END();
//=================TITLE================================================================================================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorRed)+ "BHS" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorRed) +
" - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorRed)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorRed)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+
WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-30);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-40);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-35);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-30);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-40);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-35);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
AlertIf( Ref(Buy,-1), "SOUND C:\\Windows\\Media\\Windows XP Startup.wav", "Buy", 2 );
AlertIf( Ref(Sell,-1), "SOUND C:\\Windows\\Media\\Ringin.wav", "Sell", 2 );
_SECTION_END();

_SECTION_BEGIN("trending ribbon");
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorPink )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();
GraphXSpace=15;
_SECTION_BEGIN("Magnified Market Price");
//by Vidyasagar, [email protected]//
FS=Param("Font Size",30,30,100,1);
GfxSelectFont("Arial", FS, 900, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorYellow) );
Hor=Param("Horizontal Position",400,400,400,400);
Ver=Param("Vertical Position",27,27,27,27);
GfxTextOut(""+C,Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
_SECTION_END();
 

casoni

Well-Known Member
#7
Hello,
i have checked on Bar Replay and its working well..


SetChartBkGradientFill( ParamColor( "TopColor", ColorRGB( 217, 197, 137 ) ), ParamColor( "BottomColor", ColorRGB( 254, 244, 224 ) ) );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

_SECTION_BEGIN("BHS");
SetBarsRequired(200,0);

GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k = Optimize("K",Param("K",1,0.25,5,0.25),0.25,5,0.25) ;
Per= Optimize("atr",Param("atr",4,3,20,1),3,20,1);
HACLOSE=(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorGreen, styleCandle | styleNoLabel );
j=Haclose;


//=========================Indicator================ ======
f=ATR(14);
rfsctor = WMA(H-L, Per);
revers = k * rfsctor;
Trend = 1;
NW[0] = 0;
for(i = 1; i < BarCount; i++)
{
if(Trend[i-1] == 1)
{
if(j < NW[i-1])
{
Trend = -1;
NW = j + Revers;
}
else
{
Trend = 1;
if((j - Revers) > NW[i-1])
{
NW = j - Revers;
}
else
{
NW = NW[i-1];
}
}
}
if(Trend[i-1] == -1)
{
if(j > NW[i-1])
{
Trend = 1;
NW = j - Revers;
}
else
{
Trend = -1;
if((j + Revers) < NW[i-1])
{
NW = j + Revers;
}
else
{
NW = NW[i-1];
}
}
}
}

//===============system================

Buy=Cross(j,nw);
Cover=Cross(j,nw);
Sell=Cross(nw,j);
Short=Cross(nw,j);
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );

barcomplete = BarIndex() < LastValue(BarIndex());
//AlertIf( barcomplete AND Buy, "", "NMA-Buy ", 1 );
AlertIf( barcomplete AND Buy, "SOUND C:\\Windows\\Media\\notify.wav", "Audio alert", 1 );
//AlertIf( barcomplete AND Sell, "", "NMA-Sell", 2 );
AlertIf( barcomplete AND Sell, "SOUND C:\\Windows\\Media\\chimes.wav", "Audio alert", 2 );
//AlertIf( barcomplete AND Short, "", "NMA-Short", 3 );
AlertIf( barcomplete AND Short, "SOUND C:\\Windows\\Media\\chord.wav", "Audio alert", 3 );
//AlertIf( barcomplete AND Cover, "", "NMA-Cover", 4 );
AlertIf( barcomplete AND Cover, "SOUND C:\\Windows\\Media\\ringout.wav", "Audio alert", 4 );



_SECTION_END();
_SECTION_BEGIN("ema5,13sound");
x = EMA(Close,5);
y = EMA(Close,13);
Plot(EMA(Close,5),"",colorBlue,styleLine, styleThick);
Plot(EMA(Close,13),"",colorRed,styleLine, styleThick);
XR=(EMA(Close,5) * (2 / 6 - 1) - EMA(Close,13) * (2 / 11 - 1)) / (2 / 6 - 2 / 11);
_SECTION_END();
//=================TITLE============================ ================================================== ==================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorRed)+ "BHS" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorRed) +
" - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorRed)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorRed)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+
WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-30);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-40);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-35);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-30);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-40);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-35);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();

_SECTION_BEGIN("trending ribbon");
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorPink )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();
GraphXSpace=15;
_SECTION_BEGIN("Magnified Market Price");
//by Vidyasagar, [email protected]//
FS=Param("Font Size",30,30,100,1);
GfxSelectFont("Arial", FS, 900, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorYellow) );
Hor=Param("Horizontal Position",400,400,400,400);
Ver=Param("Vertical Position",27,27,27,27);
GfxTextOut(""+C,Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
_SECTION_END();
thank you
 

casoni

Well-Known Member
#8
hello casoni, tell me can i add sound effect in amibroker when my price reach to my target price.

For eg. I purchase Bank nifty @ 10500 and my target is 10650 and stoploss is 10475.

I want to set alert if price reach to 10650 and second alert if price reach to my stop loss price 10475.


thank you in advance.
kumudhan,
Yes..
you can use .. same code , condition is , that you need to define sell-cover rules
if you get buy at 10650 , then you sell at 10650 or 10475, i.e [ target archived or stop loss hit]
define your sell and cover conditions properly

thank you
 
#9
kumudhan,
Yes..
you can use .. same code , condition is , that you need to define sell-cover rules
if you get buy at 10650 , then you sell at 10650 or 10475, i.e [ target archived or stop loss hit]
define your sell and cover conditions properly

thank you
Thanks sir ....

plz tell me how to check settings so that i can enable sound ? and if u have any buy sell signal chart plz post will be usefull and helpfull for me ..

Thanks again ...
 

casoni

Well-Known Member
#10
try this ..
this based on ema cross
this will buy when ema(c,5) crosses ema(c,20).
once you are in trade..you have 15 points target. [ adjustable from parameter window ], it will Sell at target level or
if price reverses it will exit at ema(c,5) ..
HTML:
e1=EMA(C,5);
e2=EMA(C,20);
Plot(C,"Close",3,64);
Plot(e1,"",6,1);
Plot(e2,"",4,1);

b1=Cross(e1,e2);
s1=Cross(e2,e1);
Buysetup=Flip(b1,s1);
Shortsetup=Flip(s1,b1);
trend=IIf(BarsSince(Buysetup)>BarsSince(Shortsetup ),1,0);
L2=e2;
H2=e2;
s5d=TrendSL=IIf(trend==1,L2,H2);
t1=Param("Set Target points",15,5,100,1);
BOS=IIf(e1>e2,1,-1);
Price=ValueWhen(IIf(Bos==1,b1,s1),C);
T1=IIf(BOS==1,(Price+t1),(Price-t1));
buyBars=BarsSince(Cross(e1,e2));
sellBars=BarsSince(Cross(e2,e1));
DisPds=LastValue(IIf(Bos==1,buybars,sellbars))+1;
BackPds=0;
T1A=ValueWhen(DisPds,Ref(Ref(T1,-BackPds),BackPds));
Plot(T1A,"Target",IIf(Bos==1,5,4),24);

EndDay = ParamTime( "No trade after ", "15:00:00" );
EndDay2 = ParamTime( "close position ", "15:15:00" );
tn = TimeNum();
dn = DateNum();
Exit = Ref( tn < EndDay2, -1 ) AND ( tn >= EndDay2 OR dn < Ref( dn, 1 ) );

Buy = B1 AND Tn<EndDay;
Short= S1 AND Tn<EndDay;
Sell=Shortsetup OR Cross(t1a,C) OR exit;
Cover=Buysetup OR Cross(C,t1a) OR exit;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorGreen, 0,Low,-15);
PlotShapes(IIf(Sell, shapeHollowDownArrow, shapeNone),colorOrange, 0,High,-25);
PlotShapes(IIf(Cover, shapeHollowUpArrow, shapeNone),colorLime, 0,Low,-25);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorRed, 0,High,-15);


barcomplete = BarIndex() < LastValue(BarIndex());
//AlertIf( barcomplete AND Buy, "", "NMA-Buy ", 1 );
AlertIf( barcomplete AND Buy, "SOUND C:\\Windows\\Media\\notify.wav", "Audio alert", 1 );
//AlertIf( barcomplete AND Sell, "", "NMA-Sell", 2 );
AlertIf( barcomplete AND Sell, "SOUND C:\\Windows\\Media\\chimes.wav", "Audio alert", 2 );
//AlertIf( barcomplete AND Short, "", "NMA-Short", 3 );
AlertIf( barcomplete AND Short, "SOUND C:\\Windows\\Media\\chord.wav", "Audio alert", 3 );
//AlertIf( barcomplete AND Cover, "", "NMA-Cover", 4 );
AlertIf( barcomplete AND Cover, "SOUND C:\\Windows\\Media\\ringout.wav", "Audio alert", 4 );

side = 3;//
dist = Param("text up-dn",0.1,0,2,0.1);
for( i = 1; i < BarCount; i++ )
{
if(i+side== BarCount) PlotText( "T.Stop " + e2[ i ], i+5, e2[ i ]-dist[i], colorLime );
}
thank you
 

Similar threads