With the script below, I hear an alert every time the alert condition changes. But in flat markets, I hear the up, down, up, down alerts sometimes four times in 5 seconds. Is there a way to add a delay (of say 5 seconds) so that a change in condition will not be checked for until the 5 seconds has elapsed?
Thanks
Shaeffer
An afterthought .. I could try changing the first condition to say:
if(nMACD>(nMACD1 +.05) ....., but then I might miss some alerts
Thanks
Shaeffer
An afterthought .. I could try changing the first condition to say:
if(nMACD>(nMACD1 +.05) ....., but then I might miss some alerts
PHP Code:
if (getValue("rawtime",0) != nLastRawTime) {
if(nMACD> nMACD1 && count != 1){ //First Time Rising
Alert.playSound("SOUND19.wav");
Alert.addToList(getSymbol(),"MACDc-"+getInterval()+" Up",Color.green,Color.green);
//nLastRawTime = getValue("rawtime",0);
count=1;
}else if(nMACD < nMACD1 && count != 2){ // First Time Falling
Alert.playSound("SOUND20.wav");
Alert.addToList(getSymbol(),"MACDc-"+getInterval()+" Dn",Color.red,Color.red);
//nLastRawTime = getValue("rawtime",0);
count = 2
}
}
Comment