I'm also having a bit of trouble accessing an event from another symbol and if that event = true then DrawRelativeText/Shape/Icon on current chart when that event happens.
For example:
I want the EFS to post a "B" on the chart of the ES #F, when the close() of symbol = "$VIX" crosses below it's 50MA on a 1 min chart.
How do I write that in EFS? I cannot figure it out for the life of me and it's driving me crazy.
Thanks in advance.
Here is what I have currently:
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
var vVWMA20 = new MAStudy(20, 0, "Close", MAStudy.VOLUMEWEIGHTED);
var vSMA50 = new MAStudy(50, 0, "Close", MAStudy.SIMPLE);
var vSMA200 = new MAStudy(200, 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("8MA-20MA X 50MA CrossEDITOR");
setCursorLabelName("HIGH", 0);
setCursorLabelName("LOW", 1);
setDefaultBarStyle(PS_DASH, 0);
setDefaultBarStyle(PS_DASH, 1);
setDefaultBarFgColor(Color.black, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarThickness(3, 0);
setDefaultBarThickness(3, 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 (
vSMA200.getValue(MAStudy.MA, -1) == null
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
Strategy.isShort() == false &&
vEMA8.getValue(MAStudy.MA, 1) > vSMA50.getValue(MAStudy.MA, 1) &&
vVWMA20.getValue(MAStudy.MA, 1) >= vSMA50.getValue(MAStudy.MA, 1) &&
close(1, 5, "VIX") > vSMA50.getValue(MAStudy.MA, 1) &&
close() == vSMA200.getValue(MAStudy.MA, 1)
) onAction2()
//}}EFSWizard_Expression_2
//{{EFSWizard_Expression_3
else if (
vSMA200.getValue(MAStudy.MA, -1) == null
) onAction3()
//}}EFSWizard_Expression_3
//{{EFSWizard_Expression_4
else if (
Strategy.isLONG == false &&
vEMA8.getValue(MAStudy.MA, -1) < vSMA50.getValue(MAStudy.MA, -1) &&
vEMA8.getValue(MAStudy.MA) > vSMA50.getValue(MAStudy.MA) &&
vVWMA20.getValue(MAStudy.MA, 1) < vSMA50.getValue(MAStudy.MA, 1) &&
close(1, 5, "VIX") < vSMA50.getValue(MAStudy.MA, 1) &&
close() < vSMA200.getValue(MAStudy.MA, 1)
) onAction4();
//}}EFSWizard_Expression_4
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return new Array(
high(),
low()
);
//}}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_Action_2
function onAction2() {
if (vLastAlert != 2) drawShapeRelative(0, high(), Shape.DOWNARROW, "", Color.RGB(255,0,0), Shape.TOP);
setBarBgColor(Color.RGB(0,128,0));
Strategy.doShort("GET SHORT", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//{{EFSWizard_Action_3
function onAction3() {
vLastAlert = 3;
}
//}}EFSWizard_Action_3
//{{EFSWizard_Action_4
function onAction4() {
setBarBgColor(Color.RGB(0,128,0));
Strategy.doLong("GET LONG", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
if (vLastAlert != 4) drawShapeRelative(0, low(), Shape.UPARROW, "", Color.RGB(0,255,0), Shape.BOTTOM);
vLastAlert = 4;
}
//}}EFSWizard_Action_4
//}}EFSWizard_Actions
For example:
I want the EFS to post a "B" on the chart of the ES #F, when the close() of symbol = "$VIX" crosses below it's 50MA on a 1 min chart.
How do I write that in EFS? I cannot figure it out for the life of me and it's driving me crazy.
Thanks in advance.
Here is what I have currently:
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
var vVWMA20 = new MAStudy(20, 0, "Close", MAStudy.VOLUMEWEIGHTED);
var vSMA50 = new MAStudy(50, 0, "Close", MAStudy.SIMPLE);
var vSMA200 = new MAStudy(200, 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("8MA-20MA X 50MA CrossEDITOR");
setCursorLabelName("HIGH", 0);
setCursorLabelName("LOW", 1);
setDefaultBarStyle(PS_DASH, 0);
setDefaultBarStyle(PS_DASH, 1);
setDefaultBarFgColor(Color.black, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarThickness(3, 0);
setDefaultBarThickness(3, 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 (
vSMA200.getValue(MAStudy.MA, -1) == null
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
Strategy.isShort() == false &&
vEMA8.getValue(MAStudy.MA, 1) > vSMA50.getValue(MAStudy.MA, 1) &&
vVWMA20.getValue(MAStudy.MA, 1) >= vSMA50.getValue(MAStudy.MA, 1) &&
close(1, 5, "VIX") > vSMA50.getValue(MAStudy.MA, 1) &&
close() == vSMA200.getValue(MAStudy.MA, 1)
) onAction2()
//}}EFSWizard_Expression_2
//{{EFSWizard_Expression_3
else if (
vSMA200.getValue(MAStudy.MA, -1) == null
) onAction3()
//}}EFSWizard_Expression_3
//{{EFSWizard_Expression_4
else if (
Strategy.isLONG == false &&
vEMA8.getValue(MAStudy.MA, -1) < vSMA50.getValue(MAStudy.MA, -1) &&
vEMA8.getValue(MAStudy.MA) > vSMA50.getValue(MAStudy.MA) &&
vVWMA20.getValue(MAStudy.MA, 1) < vSMA50.getValue(MAStudy.MA, 1) &&
close(1, 5, "VIX") < vSMA50.getValue(MAStudy.MA, 1) &&
close() < vSMA200.getValue(MAStudy.MA, 1)
) onAction4();
//}}EFSWizard_Expression_4
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return new Array(
high(),
low()
);
//}}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_Action_2
function onAction2() {
if (vLastAlert != 2) drawShapeRelative(0, high(), Shape.DOWNARROW, "", Color.RGB(255,0,0), Shape.TOP);
setBarBgColor(Color.RGB(0,128,0));
Strategy.doShort("GET SHORT", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//{{EFSWizard_Action_3
function onAction3() {
vLastAlert = 3;
}
//}}EFSWizard_Action_3
//{{EFSWizard_Action_4
function onAction4() {
setBarBgColor(Color.RGB(0,128,0));
Strategy.doLong("GET LONG", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
if (vLastAlert != 4) drawShapeRelative(0, low(), Shape.UPARROW, "", Color.RGB(0,255,0), Shape.BOTTOM);
vLastAlert = 4;
}
//}}EFSWizard_Action_4
//}}EFSWizard_Actions
Comment