I'm trying to set up a study in which one of the conditions is that the closing price is greater than the 200 day sma. I've added the "MASTUDY" and put 200 in the "length line but it still plots when price is above and below the 200 sma.
Any help would be appreciated.
Here's the code from the formula wizard -
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vSMA200 = new MAStudy(200, 0, "Close", MAStudy.SIMPLE);
var vSMA5 = new MAStudy(5, 0, "Close", MAStudy.SIMPLE);
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("3Day H-L");
setCursorLabelName("tri", 0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.cyan, 0);
setDefaultBarThickness(3, 0);
setPlotType(PLOTTYPE_SQUARE, 0);
//}}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(0) >= vSMA200.getValue(MAStudy.MA) &&
close() <= vSMA5.getValue(MAStudy.MA) &&
high(-2) < high(-3) &&
low(-2) < low(-3) &&
high(-1) < high(-2) &&
low(-1) < low(-2) &&
high() < high(-1) &&
low() < low(-1)
) onAction1();
//}}EFSWizard_Expression_1
//}}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() {
drawShapeRelative(0, low(), Shape.SQUARE, "", Color.RGB(255,255,255), Shape.LEFT);
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//}}EFSWizard_Actions
Any help would be appreciated.
Here's the code from the formula wizard -
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vSMA200 = new MAStudy(200, 0, "Close", MAStudy.SIMPLE);
var vSMA5 = new MAStudy(5, 0, "Close", MAStudy.SIMPLE);
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("3Day H-L");
setCursorLabelName("tri", 0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.cyan, 0);
setDefaultBarThickness(3, 0);
setPlotType(PLOTTYPE_SQUARE, 0);
//}}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(0) >= vSMA200.getValue(MAStudy.MA) &&
close() <= vSMA5.getValue(MAStudy.MA) &&
high(-2) < high(-3) &&
low(-2) < low(-3) &&
high(-1) < high(-2) &&
low(-1) < low(-2) &&
high() < high(-1) &&
low() < low(-1)
) onAction1();
//}}EFSWizard_Expression_1
//}}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() {
drawShapeRelative(0, low(), Shape.SQUARE, "", Color.RGB(255,255,255), Shape.LEFT);
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//}}EFSWizard_Actions
Comment