Hello,
I am trying to trigger an alert when the Stoch crosses 80/20 and confirmed MACD slow crosses over on a 3 min chart. I used the wizard to create the code.
The problem that i face is that it triggers on every bar closed and does not just trigger on the actual crossovers. This kind of jams my system with the alerts flying off.
Also, can i have one alert triggered on two different time frames..with the same indicators.
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vMACD4_13 = new MACDStudy(4, 13, 5, "Close", false);
var vMACD4_13_2 = new MACDStudy(4, 13, 5, "Close", false);
var vStoch5_3 = new StochStudy(5, 3, 1);
var vLastAlert = -1;
//}}EFSWizard_Declarations
function preMain() {
/**
* This function is called only once, before any of the bars are loaded.
* Place any study or EFS configuration commands here.
*/
//{{EFSWizard_PreMain
setPriceStudy(true);
setStudyTitle("MACD Cross-over");
setCursorLabelName("cross", 0);
setDefaultBarStyle(PS_DOT, 0);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarThickness(1, 0);
setPlotType(PLOTTYPE_LINE, 0);
setComputeOnClose(true);
//}}EFSWizard_PreMain
}
function main() {
/**
* The main() function is called once per bar on all previous bars, once per
* each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
* in your preMain(), it is also called on every tick.
*/
//{{EFSWizard_Expressions
//{{EFSWizard_Expression_1
if (
vMACD4_13.getValue(MACDStudy.SIGNAL) < vMACD4_13.getValue(MACDStudy.MACD)
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
vMACD4_13.getValue(MACDStudy.SIGNAL) > vMACD4_13.getValue(MACDStudy.MACD)
) onAction2()
//}}EFSWizard_Expression_2
//{{EFSWizard_Expression_3
else if (
vStoch5_3.getValue(StochStudy.SLOW) < vStoch5_3.getValue(StochStudy.FAST)
) onAction3()
//}}EFSWizard_Expression_3
//{{EFSWizard_Expression_4
else if (
vStoch5_3.getValue(StochStudy.SLOW) > vStoch5_3.getValue(StochStudy.FAST)
) onAction4();
//}}EFSWizard_Expression_4
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return ;
//}}EFSWizard_Return
}
function postMain() {
/**
* The postMain() function is called only once, when the EFS is no longer used for
* the current symbol (ie, symbol change, chart closing, or application shutdown).
*/
}
//{{EFSWizard_Actions
//{{EFSWizard_Action_1
function onAction1() {
Alert.addToList(getSymbol(), "MACD Signal Cross Down", Color.RGB(0,0,0), Color.RGB(195,0,0));
Alert.playSound("C:\\Program Files\\esignal\\Workstation\\Sounds\\Ding.wav");
drawShapeRelative(0, high(), Shape.DOWNARROW, "", Color.RGB(155,0,0), Shape.BOTTOM);
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
Alert.addToList(getSymbol(), "MACD Signal Cross Up", Color.RGB(0,0,0), Color.RGB(195,0,0));
Alert.playSound("C:\\Program Files\\esignal\\Workstation\\Sounds\\Ding.wav");
drawShapeRelative(0, low(), Shape.UPARROW, "", Color.RGB(155,0,0), Shape.TOP);
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//{{EFSWizard_Action_3
function onAction3() {
Alert.addToList(getSymbol(), "Stoch Cross Down", Color.RGB(0,0,0), Color.RGB(195,0,0));
Alert.playSound("C:\\Program Files\\esignal\\Workstation\\Sounds\\Ding.wav");
drawShapeRelative(0, high(), Shape.DOWNARROW, "", Color.RGB(155,0,0), Shape.TOP);
vLastAlert = 3;
}
//}}EFSWizard_Action_3
//{{EFSWizard_Action_4
function onAction4() {
Alert.addToList(getSymbol(), "Stoc Cross Up", Color.RGB(0,0,0), Color.RGB(195,0,0));
Alert.playSound("C:\\Program Files\\esignal\\Workstation\\Sounds\\Ding.wav");
drawShapeRelative(0, high(), Shape.UPARROW, "", Color.RGB(155,0,0), Shape.BOTTOM);
vLastAlert = 4;
}
//}}EFSWizard_Action_4
//}}EFSWizard_Actions
Thanks
-Shiva
I am trying to trigger an alert when the Stoch crosses 80/20 and confirmed MACD slow crosses over on a 3 min chart. I used the wizard to create the code.
The problem that i face is that it triggers on every bar closed and does not just trigger on the actual crossovers. This kind of jams my system with the alerts flying off.
Also, can i have one alert triggered on two different time frames..with the same indicators.
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vMACD4_13 = new MACDStudy(4, 13, 5, "Close", false);
var vMACD4_13_2 = new MACDStudy(4, 13, 5, "Close", false);
var vStoch5_3 = new StochStudy(5, 3, 1);
var vLastAlert = -1;
//}}EFSWizard_Declarations
function preMain() {
/**
* This function is called only once, before any of the bars are loaded.
* Place any study or EFS configuration commands here.
*/
//{{EFSWizard_PreMain
setPriceStudy(true);
setStudyTitle("MACD Cross-over");
setCursorLabelName("cross", 0);
setDefaultBarStyle(PS_DOT, 0);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarThickness(1, 0);
setPlotType(PLOTTYPE_LINE, 0);
setComputeOnClose(true);
//}}EFSWizard_PreMain
}
function main() {
/**
* The main() function is called once per bar on all previous bars, once per
* each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
* in your preMain(), it is also called on every tick.
*/
//{{EFSWizard_Expressions
//{{EFSWizard_Expression_1
if (
vMACD4_13.getValue(MACDStudy.SIGNAL) < vMACD4_13.getValue(MACDStudy.MACD)
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
vMACD4_13.getValue(MACDStudy.SIGNAL) > vMACD4_13.getValue(MACDStudy.MACD)
) onAction2()
//}}EFSWizard_Expression_2
//{{EFSWizard_Expression_3
else if (
vStoch5_3.getValue(StochStudy.SLOW) < vStoch5_3.getValue(StochStudy.FAST)
) onAction3()
//}}EFSWizard_Expression_3
//{{EFSWizard_Expression_4
else if (
vStoch5_3.getValue(StochStudy.SLOW) > vStoch5_3.getValue(StochStudy.FAST)
) onAction4();
//}}EFSWizard_Expression_4
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return ;
//}}EFSWizard_Return
}
function postMain() {
/**
* The postMain() function is called only once, when the EFS is no longer used for
* the current symbol (ie, symbol change, chart closing, or application shutdown).
*/
}
//{{EFSWizard_Actions
//{{EFSWizard_Action_1
function onAction1() {
Alert.addToList(getSymbol(), "MACD Signal Cross Down", Color.RGB(0,0,0), Color.RGB(195,0,0));
Alert.playSound("C:\\Program Files\\esignal\\Workstation\\Sounds\\Ding.wav");
drawShapeRelative(0, high(), Shape.DOWNARROW, "", Color.RGB(155,0,0), Shape.BOTTOM);
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
Alert.addToList(getSymbol(), "MACD Signal Cross Up", Color.RGB(0,0,0), Color.RGB(195,0,0));
Alert.playSound("C:\\Program Files\\esignal\\Workstation\\Sounds\\Ding.wav");
drawShapeRelative(0, low(), Shape.UPARROW, "", Color.RGB(155,0,0), Shape.TOP);
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//{{EFSWizard_Action_3
function onAction3() {
Alert.addToList(getSymbol(), "Stoch Cross Down", Color.RGB(0,0,0), Color.RGB(195,0,0));
Alert.playSound("C:\\Program Files\\esignal\\Workstation\\Sounds\\Ding.wav");
drawShapeRelative(0, high(), Shape.DOWNARROW, "", Color.RGB(155,0,0), Shape.TOP);
vLastAlert = 3;
}
//}}EFSWizard_Action_3
//{{EFSWizard_Action_4
function onAction4() {
Alert.addToList(getSymbol(), "Stoc Cross Up", Color.RGB(0,0,0), Color.RGB(195,0,0));
Alert.playSound("C:\\Program Files\\esignal\\Workstation\\Sounds\\Ding.wav");
drawShapeRelative(0, high(), Shape.UPARROW, "", Color.RGB(155,0,0), Shape.BOTTOM);
vLastAlert = 4;
}
//}}EFSWizard_Action_4
//}}EFSWizard_Actions
Thanks
-Shiva
Comment