Hi guys,
I am new to the esignal product and have begun using the formula wizard to back test strategies.
I created this strategy but it doesnt seem to work when I back test it. All I get is a lot of n/a in the output box.
Could someone have a look at the script and let me know where I could be going wrong. I am pasting the script below for your information.
In words I want to go long when the ADX has been rising for 3 previous closes and is above 20 and the DM+ is above the DM- and the MACD has crossed over. The opposite for going short.
Mant thanks,
Harry Bedi
check EFS syntax
Generated EFS Code
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vADXDM = new ADXDMStudy(14);
var vParSAR = new ParabolicStudy(0.02, 0.02, 0.2);
var vMACD12_26 = new MACDStudy(12, 26, 9, "Close", false);
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("HBEDI_MOdel1");
//}}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 (
Strategy.isLong() == false &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-1) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-2) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-3) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vParSAR.getValue(ParabolicStudy.STOP) < low(-1) &&
vParSAR.getValue(ParabolicStudy.STOP) < low(-2) &&
vParSAR.getValue(ParabolicStudy.STOP) < low(-3) &&
vADXDM.getValue(ADXDMStudy.PDI, -1) > vADXDM.getValue(ADXDMStudy.NDI, -1) &&
vADXDM.getValue(ADXDMStudy.PDI, -2) > vADXDM.getValue(ADXDMStudy.NDI, -2) &&
vADXDM.getValue(ADXDMStudy.PDI, -3) > vADXDM.getValue(ADXDMStudy.NDI, -3) &&
vMACD12_26.getValue(MACDStudy.SIGNAL) < vMACD12_26.getValue(MACDStudy.MACD)
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
Strategy.isShort() == false &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-1) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-2) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) < high(-3) &&
vParSAR.getValue(ParabolicStudy.STOP) > high(-1) &&
vParSAR.getValue(ParabolicStudy.STOP) < high(-2) &&
vParSAR.getValue(ParabolicStudy.STOP) < high(-3) &&
vADXDM.getValue(ADXDMStudy.NDI, -1) > vADXDM.getValue(ADXDMStudy.PDI, -1) &&
vADXDM.getValue(ADXDMStudy.NDI, -2) > vADXDM.getValue(ADXDMStudy.PDI, -2) &&
vADXDM.getValue(ADXDMStudy.NDI, -3) > vADXDM.getValue(ADXDMStudy.PDI, -3) &&
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) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Bullet.wav");
setPriceBarColor(Color.RGB(192,220,192));
drawShapeRelative(0, low(), Shape.UPARROW, "", Color.RGB(192,220,192), Shape.BOTTOM, "Go Long");
if (vLastAlert != 1) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
if (vLastAlert != 1) Alert.addToList(getSymbol(), "Go Long", Color.RGB(0,0,0), Color.RGB(192,220,192));
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
setPriceBarColor(Color.RGB(255,0,0));
drawShapeRelative(0, low(), Shape.CIRCLE, "Go Short", Color.RGB(255,0,0), Shape.TOP);
if (vLastAlert != 2) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Boing.wav");
if (vLastAlert != 2) Strategy.doShort("Go Short", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
if (vLastAlert != 2) Alert.addToList(getSymbol(), "Go Short", Color.RGB(0,0,0), Color.RGB(255,0,0));
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//}}EFSWizard_Actions
I am new to the esignal product and have begun using the formula wizard to back test strategies.
I created this strategy but it doesnt seem to work when I back test it. All I get is a lot of n/a in the output box.
Could someone have a look at the script and let me know where I could be going wrong. I am pasting the script below for your information.
In words I want to go long when the ADX has been rising for 3 previous closes and is above 20 and the DM+ is above the DM- and the MACD has crossed over. The opposite for going short.
Mant thanks,
Harry Bedi
check EFS syntax
Generated EFS Code
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vADXDM = new ADXDMStudy(14);
var vParSAR = new ParabolicStudy(0.02, 0.02, 0.2);
var vMACD12_26 = new MACDStudy(12, 26, 9, "Close", false);
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("HBEDI_MOdel1");
//}}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 (
Strategy.isLong() == false &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-1) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-2) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-3) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vParSAR.getValue(ParabolicStudy.STOP) < low(-1) &&
vParSAR.getValue(ParabolicStudy.STOP) < low(-2) &&
vParSAR.getValue(ParabolicStudy.STOP) < low(-3) &&
vADXDM.getValue(ADXDMStudy.PDI, -1) > vADXDM.getValue(ADXDMStudy.NDI, -1) &&
vADXDM.getValue(ADXDMStudy.PDI, -2) > vADXDM.getValue(ADXDMStudy.NDI, -2) &&
vADXDM.getValue(ADXDMStudy.PDI, -3) > vADXDM.getValue(ADXDMStudy.NDI, -3) &&
vMACD12_26.getValue(MACDStudy.SIGNAL) < vMACD12_26.getValue(MACDStudy.MACD)
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
Strategy.isShort() == false &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-1) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) > high(-2) &&
vADXDM.getValue(ADXDMStudy.ADX) > 20 &&
vADXDM.getValue(ADXDMStudy.ADX) < high(-3) &&
vParSAR.getValue(ParabolicStudy.STOP) > high(-1) &&
vParSAR.getValue(ParabolicStudy.STOP) < high(-2) &&
vParSAR.getValue(ParabolicStudy.STOP) < high(-3) &&
vADXDM.getValue(ADXDMStudy.NDI, -1) > vADXDM.getValue(ADXDMStudy.PDI, -1) &&
vADXDM.getValue(ADXDMStudy.NDI, -2) > vADXDM.getValue(ADXDMStudy.PDI, -2) &&
vADXDM.getValue(ADXDMStudy.NDI, -3) > vADXDM.getValue(ADXDMStudy.PDI, -3) &&
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) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Bullet.wav");
setPriceBarColor(Color.RGB(192,220,192));
drawShapeRelative(0, low(), Shape.UPARROW, "", Color.RGB(192,220,192), Shape.BOTTOM, "Go Long");
if (vLastAlert != 1) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
if (vLastAlert != 1) Alert.addToList(getSymbol(), "Go Long", Color.RGB(0,0,0), Color.RGB(192,220,192));
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
setPriceBarColor(Color.RGB(255,0,0));
drawShapeRelative(0, low(), Shape.CIRCLE, "Go Short", Color.RGB(255,0,0), Shape.TOP);
if (vLastAlert != 2) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Boing.wav");
if (vLastAlert != 2) Strategy.doShort("Go Short", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
if (vLastAlert != 2) Alert.addToList(getSymbol(), "Go Short", Color.RGB(0,0,0), Color.RGB(255,0,0));
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//}}EFSWizard_Actions
Comment