I have this indicator, i need help to add sound or alert in it.
it should play sound every time it draws UP or down arrow.
I played with playSound() and alert(), but both of them making the sound continuously, every tick.
It should play sound only once every time it plots an up/down arrorw.
The indicator is simple ATR based volatility btreakout.
I don’t know where you are putting the playsound() and alert() functions but they should be within each of the two if statements at the bottom of your code…not outside of them. if they are outside, they execute every tick regardless of any restrictive parameters you may have later on in the code…if they are within the if statements they only execute IF x,y,z…happens
I have been trying to add sound alerts to the code too and same result [although puting it within the if statements] maybe something’s wrong with the code?
int start()
{
int i,limit, counter;
int counted_bars=IndicatorCounted();
double range, avgrange, atrnow;
limit=Bars-counted_bars; //
for(i=0; i<=limit; i++)
{
counter=i;
range=0;
avgrange=0;
for(counter=i; counter<=i+9; counter++) //For operator to calculate Total Range 1-10
{
avgrange=avgrange+MathAbs(High[counter]-Low[counter]); //Average Range; used for displacement of Arrow
}
range=avgrange/10;
atrnow=iATR(NULL,0,14,i)*ATRmulti; //ATRnow=ATR at current bar * ATR factor
if(High[i]-Low[i]>atrnow && Open[i]>Close[i]) //Arrow only showed if ATRnow greater than range
{
Alert("Volatility! up");
Down[i]=High[i]+range; //When Criteria met Arrow is shown
}else