How to add Alert Sound

pareshR

Well-Known Member
#1
i got this afl from http://www.wisestocktrader.com/indicators/4269-nifty-supertrend-system

i want to add alert SOUND for buy n sell signals

i added after "plot shapes" following lines but its not working


" AlertIf( Buy, "SOUND C:\\Windows\\Media\\disconnect_11.wav", "Audio alert", 1 );
AlertIf( Short, "SOUND C:\\Windows\\Media\\cuckoo.wav", "Audio alert", 2 );




pls help

//////////////////////////////////////////////////


_SECTION_BEGIN("NIFTY SuperTrend");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartOptions(1,chartShowArrows|chartShowDates|chartWrapTitle);


GraphXSpace = 15;

SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
SetChartBkGradientFill( ParamColor( "TopColor", ColorRGB( 0, 255, 255 ) ), ParamColor( "BottomColor", ColorRGB( 0, 255, 255 ) ) );

//SetTradeDelays(1,1,1,1);
Period = Param("Period", 800, 1, 2400, 1);
mult = Param("Multiplier", 8, 1.1, 20.0, 0.01); // 5 minutes chart.

f=ATR(period);

VS[0] = Close[0];
trend[0] = 0;
HighC[0]=0;
Lowc[0]=0;

for( i = period+1; i < BarCount; i++ )
{

vs = vs[i-1];
trend = trend[i-1];
highC = HighC[i-1];
lowc = lowc[i-1];

if ((trend>=0) && ( C <VS ))
{
trend =-1;
HighC = C;
lowc = C;
}

if ((trend<=0) && (C >VS))
{
trend=1;
HighC = C;
lowc = C;
}

if (trend==-1)
{
if (C<lowc) lowc = C;
VS= lowc+ (mult*f);
}


if (trend==1)
{
if (C>HighC) HighC = C;
VS= HighC-(mult*f);
}

}

Plot(VS, "Vol Stop",IIf(trend==1,colorRed,colorYellow ),styleThick);

Buy=Cross(Trend,0);
Short=Cross(0, Trend);
Buy = Ref(Buy, -1);
Short = Ref(Short, -1);

Hp = HHV( H, 40 );
Lp = LLV( L, 40 );

BarsSincebuy = BarsSince( Buy );
BarsSinceshort = BarsSince( Short );
LastSignal = IIf( BarsSincebuy < BarsSinceshort, 1, -1 );
Sig = WriteIf( BarsSincebuy < BarsSinceshort, "BUY", "SELL" );

slPrice = IIf( LastSignal == 1, HighestSince( Buy, Lp ), LowestSince( Short, Hp ) );
initialrisk = IIf( LastSignal == 1, BuyPrice - SLPrice, SLPrice - ShortPrice );
CurrentPL = IIf( LastSignal == 1, C - BuyPrice, SellPrice - C );

BuyPrice=ValueWhen(Buy,O);
ShortPrice=ValueWhen(Short,O);

entry = IIf( LastSignal == 1, BuyPrice, ShortPrice );

PlotShapes(Buy * shapeUpArrow,colorDarkGreen, 0,L, Offset=-45);
PlotShapes(Short * shapeDownArrow,colorDarkRed, 0,H, Offset=-45);


bars = LastValue( IIf(BarsSincebuy < BarsSinceshort, BarsSincebuy, BarsSinceshort));
Offset = 15;
Clr = IIf(LastValue(LastSignal) == 1, colorGreen, colorRed);


if ( ParamToggle( "Message Board ", "Show|Hide", 1 ) )
{
GfxSelectFont( "Tahoma", 11, 700 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( SelectedValue( LastSignal ) == 1 )
{
GfxSelectSolidBrush( colorDarkGreen );
Datetim = "" + ValueWhen( Buy, Day(), 1 ) + "/" + ValueWhen( Buy, Month(), 1 ) + "/" + ValueWhen( Buy, Year(), 1 ) + " " + ValueWhen( Buy, Hour(), 1 ) + ":" + ValueWhen( Buy, Minute(), 1 );
}
else
{
GfxSelectSolidBrush( colorDarkRed );
Datetim = "" + ValueWhen( Short, Day(), 1 ) + "/" + ValueWhen( Short, Month(), 1 ) + "/" + ValueWhen( Short, Year(), 1 ) + " " + ValueWhen( Short, Hour(), 1 ) + ":" + ValueWhen( Short, Minute(), 1 );
}

pxHeight = Status( "pxchartheight" ) ;

xx = Status( "pxchartwidth" );
Left = 1100;
width = 310;
x = 1.5;
x2 = 250;

y = pxHeight / 1;

GfxSelectPen( colorLightBlue, 1 );
GfxRoundRect( x, y - 105, x2, y , 7, 7 ) ;
GfxTextOut( ( "NIFTY SUPERTREND SYSTEM" ), 25, y - 105 );
GfxTextOut( ( "Last Signal" ), 10, y - 65 ) ;
GfxTextOut( ( ": " + Datetim ), 115, y - 65 ) ;
GfxTextOut( ( "" + sig + " Entry @" ), 10, y - 45 );
GfxTextOut( ( ": " + entry ), 110, y - 45 );
GfxTextOut( ( "Current P/L" ), 10, y - 25 );
GfxTextOut( ( ": " + WriteVal( IIf( sig == "BUY", ( C - entry ), ( entry - C ) ), 2.2 ) ), 110, y - 25);;
x = 290;
x2 = 500;

}

_SECTION_END();

_SECTION_BEGIN("L.T.P.");
cx = Param( "cxposn", 1000, 0, 1250, 1 );
cy = Param( "cyposn", 25, 0, 500, 1 );
GfxSelectFont( "Candara", 18, 98, False );
gfxcup = SelectedValue(C > Ref(C,-1));
gfxpcolor = IIf(gfxcup,colorDarkGreen,colorDarkRed);
GfxSetTextColor(gfxpcolor);
//GfxSetTextColor( colorWhite );
GfxTextOut( "L.T.P. " + C + " ", cx, cy );
_SECTION_END();

_SECTION_BEGIN("trend");
uptrend= Signal(29)<MACD(13);
downtrend= Signal(29)>MACD(13);
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();
 
#2
Modify as -

Buy=Cross(Trend,0);
Short=Cross(0, Trend);
Buy = Ref(Buy, -1);
Short = Ref(Short, -1);

if (SelectedValue(Buy)==1) Say("BUY Signal Now ");
if (SelectedValue(Short)==1) Say("Sell Signal Now");

Hp = HHV( H, 40 );
Lp = LLV( L, 40 );
 

rrrajguru

Well-Known Member
#3
" AlertIf( Buy, "SOUND C:\\Windows\\Media\\disconnect_11.wav", "Audio alert", 1 );
AlertIf( Short, "SOUND C:\\Windows\\Media\\cuckoo.wav", "Audio alert", 2 );
Please add these two lines instead of upper two lines and see whether it is working or not. And be sure both the wav files are there in the path.

AlertIf( Short, "SOUND C:\\Windows\\Media\\cuckoo.wav", "Audio alert", 2 );
AlertIf( Buy, "SOUND C:\\Windows\\Media\\disconnect_11.wav", "Audio alert", 2 );
 

Similar threads