Hi,
I’m trying to make my own indicator on EFS. I want to get the difference between 2 moving averages and plot that line, and I also want to plot the moving average of that difference. I can plot the difference ok but I can’t plot the moving average of the difference. Basically I’m trying to make something like a MACD but I don’t want to use exponential averages so it has to be a custom built study. Any help will be greatly appreciated
Thanks
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vSMA750 = new MAStudy(750, 0, "Close", MAStudy.SIMPLE);
var vEMA300 = new MAStudy(300, 0, "Close", MAStudy.EXPONENTIAL);
var vSMA100_of_vSMA750 = new MAStudy(100, 0, vSMA750, MAStudy.MA, 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(false);
setStudyTitle("MAxDiff");
setCursorLabelName("Diff", 0);
setCursorLabelName("Ave", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.blue, 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
//}}EFSWizard_Expression_1
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return new Array(
vEMA300.getValue(MAStudy.MA) - vSMA750.getValue(MAStudy.MA),
vSMA100_of_vSMA750.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() {
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//}}EFSWizard_Actions
I’m trying to make my own indicator on EFS. I want to get the difference between 2 moving averages and plot that line, and I also want to plot the moving average of that difference. I can plot the difference ok but I can’t plot the moving average of the difference. Basically I’m trying to make something like a MACD but I don’t want to use exponential averages so it has to be a custom built study. Any help will be greatly appreciated
Thanks
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vSMA750 = new MAStudy(750, 0, "Close", MAStudy.SIMPLE);
var vEMA300 = new MAStudy(300, 0, "Close", MAStudy.EXPONENTIAL);
var vSMA100_of_vSMA750 = new MAStudy(100, 0, vSMA750, MAStudy.MA, 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(false);
setStudyTitle("MAxDiff");
setCursorLabelName("Diff", 0);
setCursorLabelName("Ave", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.blue, 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
//}}EFSWizard_Expression_1
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return new Array(
vEMA300.getValue(MAStudy.MA) - vSMA750.getValue(MAStudy.MA),
vSMA100_of_vSMA750.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() {
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//}}EFSWizard_Actions
Comment