This basic alert differs from built in alerts by being set within a chart; it draws a line at the alert level. You can also pause the
klaxon so it doesn't yell constantly.
klaxon so it doesn't yell constantly.
PHP Code:
/* PriceAlert.efs -- sound when a price is touched.
Use Edit Studies to set price.
Set Pause to numSeconds to wait between sounds.
Don't setComputeOnClose--it may skip your price.
*/
function preMain() {
setPriceStudy(true);
setStudyTitle("PrAlert");
setCursorLabelName("PrAl", 0);
}
var lastAlertTime = null;
function main(numPrice, numPause) {
if (numPrice == null) numPrice = 0;
if (numPause == null) numPause = 0;
var t = null;
if (close() == numPrice)
t = getValue("rawtime");
if (t - lastAlertTime > 60) {
Alert.playSound("train.wav");
lastAlertTime = t;
}
return numPrice;
}