I am trying to write up and down arrows when the MA of 5 -1 cross with MA of 8. I have followed the examples and was able to make it work when the MacD crosses but I can not get the arrows for the MA.
Any help would be greatly appreciated!
Thanks
activedaddo
//{{EFSWizard_Declarations
var vEMA5 = new MAStudy(5, -1, "Close", MAStudy.EXPONENTIAL);
var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
var vLastAlert = -1;
//}}EFSWizard_Declarations
function preMain() {
//{{EFSWizard_Code_PreMain_setPriceBarColor
setColorPriceBars(true);
//}}EFSWizard_Code_PreMain_setPriceBarColor
/**
* 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("EMA_arrows");
setCursorLabelName("15linea", 0);
setCursorLabelName("15lineb", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
//}}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 (
close() < vEMA5.getValue(MAStudy.MA)
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
close() > vEMA5.getValue(MAStudy.MA)
) onAction2()
//}}EFSWizard_Expression_2
//{{EFSWizard_Expression_3
else if (
vEMA5.getValue(MAStudy.MA) < vEMA8.getValue(MAStudy.MA)
) onAction3()
//}}EFSWizard_Expression_3
//{{EFSWizard_Expression_4
else if (
vEMA5.getValue(MAStudy.MA) > vEMA8.getValue(MAStudy.MA)
) onAction4();
//}}EFSWizard_Expression_4
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return new Array(
vEMA5.getValue(MAStudy.MA),
vEMA8.getValue(MAStudy.MA)
);
//}}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() {
setPriceBarColor(Color.RGB(155,0,0));
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
setPriceBarColor(Color.RGB(0,255,0));
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//{{EFSWizard_Action_3
function onAction3() {
if (vLastAlert != 3) Alert.addToList(getSymbol(), "Ma Cross DN", Color.RGB(0,0,0), Color.RGB(195,0,0));
if (vLastAlert != 3) Actions.playSound("C:\\Program Files\\eSignal\\Sounds\\cowbell.wav");
if (vLastAlert != 3) drawShapeRelative(0, low(), Shape.DOWNARROW, "", Color.RGB(255,251,240), Shape.BOTTOM);
vLastAlert = 3;
}
//}}EFSWizard_Action_3
//{{EFSWizard_Action_4
function onAction4() {
if (vLastAlert != 4) Alert.addToList(getSymbol(), "Ma Cross UP", Color.RGB(0,0,0), Color.RGB(195,0,0));
if (vLastAlert != 4) Actions.playSound("C:\\Program Files\\eSignal\\Sounds\\doorbell.wav");
if (vLastAlert != 4) drawShapeRelative(0, low(), Shape.UPARROW, "", Color.RGB(255,251,240), Shape.TOP);
vLastAlert = 4;
}
//}}EFSWizard_Action_4
//}}EFSWizard_Actions
Any help would be greatly appreciated!
Thanks
activedaddo
//{{EFSWizard_Declarations
var vEMA5 = new MAStudy(5, -1, "Close", MAStudy.EXPONENTIAL);
var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
var vLastAlert = -1;
//}}EFSWizard_Declarations
function preMain() {
//{{EFSWizard_Code_PreMain_setPriceBarColor
setColorPriceBars(true);
//}}EFSWizard_Code_PreMain_setPriceBarColor
/**
* 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("EMA_arrows");
setCursorLabelName("15linea", 0);
setCursorLabelName("15lineb", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
//}}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 (
close() < vEMA5.getValue(MAStudy.MA)
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
close() > vEMA5.getValue(MAStudy.MA)
) onAction2()
//}}EFSWizard_Expression_2
//{{EFSWizard_Expression_3
else if (
vEMA5.getValue(MAStudy.MA) < vEMA8.getValue(MAStudy.MA)
) onAction3()
//}}EFSWizard_Expression_3
//{{EFSWizard_Expression_4
else if (
vEMA5.getValue(MAStudy.MA) > vEMA8.getValue(MAStudy.MA)
) onAction4();
//}}EFSWizard_Expression_4
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return new Array(
vEMA5.getValue(MAStudy.MA),
vEMA8.getValue(MAStudy.MA)
);
//}}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() {
setPriceBarColor(Color.RGB(155,0,0));
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
setPriceBarColor(Color.RGB(0,255,0));
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//{{EFSWizard_Action_3
function onAction3() {
if (vLastAlert != 3) Alert.addToList(getSymbol(), "Ma Cross DN", Color.RGB(0,0,0), Color.RGB(195,0,0));
if (vLastAlert != 3) Actions.playSound("C:\\Program Files\\eSignal\\Sounds\\cowbell.wav");
if (vLastAlert != 3) drawShapeRelative(0, low(), Shape.DOWNARROW, "", Color.RGB(255,251,240), Shape.BOTTOM);
vLastAlert = 3;
}
//}}EFSWizard_Action_3
//{{EFSWizard_Action_4
function onAction4() {
if (vLastAlert != 4) Alert.addToList(getSymbol(), "Ma Cross UP", Color.RGB(0,0,0), Color.RGB(195,0,0));
if (vLastAlert != 4) Actions.playSound("C:\\Program Files\\eSignal\\Sounds\\doorbell.wav");
if (vLastAlert != 4) drawShapeRelative(0, low(), Shape.UPARROW, "", Color.RGB(255,251,240), Shape.TOP);
vLastAlert = 4;
}
//}}EFSWizard_Action_4
//}}EFSWizard_Actions
Comment