I've been trying to make a study that plots a circle below the price bars on the Chart, when the 2 lines cross on MACD, not when MACD crosses the "0" line.
On a 233t chart at roughly 1:31pm today (6-16-08) MACD crossed to the downside but I got no circle on the chart.
Also, it doesn't always do it in real time. Sometimes it will work in real time sometimes it won't.
Anyone know the answer to these 2 problems?
Thanks,
Jeremiah
Here is the code -
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vMACD12_26 = new MACDStudy(13, 21, 8, "close", false);
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 Dot")
setComputeOnClose();
//}}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 (
vMACD12_26.getValue(MACDStudy.MACD) > vMACD12_26.getValue(MACDStudy.SIGNAL)
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
vMACD12_26.getValue(MACDStudy.SIGNAL) > vMACD12_26.getValue(MACDStudy.MACD)
) onAction2();
//}}EFSWizard_Expression_2
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return null;
//}}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() {
if (vLastAlert != 1) drawShapeRelative(0, high(0)+.25, Shape.CIRCLE, "", Color.RGB(0,255,255), Shape.TOP);
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
if (vLastAlert != 2) drawShapeRelative(0, low(0)-.1, Shape.CIRCLE, "", Color.RGB(255,255,0), Shape.BOTTOM);
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//}}EFSWizard_Actions
On a 233t chart at roughly 1:31pm today (6-16-08) MACD crossed to the downside but I got no circle on the chart.
Also, it doesn't always do it in real time. Sometimes it will work in real time sometimes it won't.
Anyone know the answer to these 2 problems?
Thanks,
Jeremiah
Here is the code -
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vMACD12_26 = new MACDStudy(13, 21, 8, "close", false);
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 Dot")
setComputeOnClose();
//}}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 (
vMACD12_26.getValue(MACDStudy.MACD) > vMACD12_26.getValue(MACDStudy.SIGNAL)
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
vMACD12_26.getValue(MACDStudy.SIGNAL) > vMACD12_26.getValue(MACDStudy.MACD)
) onAction2();
//}}EFSWizard_Expression_2
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return null;
//}}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() {
if (vLastAlert != 1) drawShapeRelative(0, high(0)+.25, Shape.CIRCLE, "", Color.RGB(0,255,255), Shape.TOP);
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
if (vLastAlert != 2) drawShapeRelative(0, low(0)-.1, Shape.CIRCLE, "", Color.RGB(255,255,0), Shape.BOTTOM);
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//}}EFSWizard_Actions
Comment