I was wondering if someone could help me with my indicator. I wrote an indicator that tells me when there are spikes of volume and it works fine but when I tried to add in an alert, the code seems to not work. Code is below. Thank you in advance!
/************************************************** *******
By the Choltron, the Doughboy, the man-monster-machine
Holla back!
************************************************** ********/
var vLastAlert = -1;
function preMain() {
setPriceStudy(true);
setStudyTitle("Spikey");
setCursorLabelName("Spikey", 0);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarThickness(2,0);
}
function main() {
if ((volume() > volume(-1)) && (2 * (sma(13, volume())) <= volume()))
onAction1()
else if ((volume() > volume(-1)) && (3 * (sma(13, volume())) <= volume()))
onAction2();
return null;
}
function postMain() {
}
function onAction1() {
if (vLastAlert != 1) Alert.addToList(getSymbol(), "Pay attention!", Color.RGB(0,0,0), Color.blue);
if (vLastAlert != 1) Alert.playSound("C:\Program Files\eSignal\Sounds\Ding.wav");
if (vLastAlert != 1) setBarBgColor(Color.blue);
vLastAlert = 1;
}
function onAction2() {
if (vLastAlert != 2) Alert.addToList(getSymbol(), "Mommy!", Color.RGB(0,0,0), Color.red);
if (vLastAlert != 2) Alert.playSound("C:\Program Files\eSignal\Sounds\Ding.wav");
if (vLastAlert != 2) setBarBgColor(Color.red);
vLastAlert = 2;
}
/************************************************** *******
By the Choltron, the Doughboy, the man-monster-machine
Holla back!
************************************************** ********/
var vLastAlert = -1;
function preMain() {
setPriceStudy(true);
setStudyTitle("Spikey");
setCursorLabelName("Spikey", 0);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarThickness(2,0);
}
function main() {
if ((volume() > volume(-1)) && (2 * (sma(13, volume())) <= volume()))
onAction1()
else if ((volume() > volume(-1)) && (3 * (sma(13, volume())) <= volume()))
onAction2();
return null;
}
function postMain() {
}
function onAction1() {
if (vLastAlert != 1) Alert.addToList(getSymbol(), "Pay attention!", Color.RGB(0,0,0), Color.blue);
if (vLastAlert != 1) Alert.playSound("C:\Program Files\eSignal\Sounds\Ding.wav");
if (vLastAlert != 1) setBarBgColor(Color.blue);
vLastAlert = 1;
}
function onAction2() {
if (vLastAlert != 2) Alert.addToList(getSymbol(), "Mommy!", Color.RGB(0,0,0), Color.red);
if (vLastAlert != 2) Alert.playSound("C:\Program Files\eSignal\Sounds\Ding.wav");
if (vLastAlert != 2) setBarBgColor(Color.red);
vLastAlert = 2;
}
Comment