OK here's the basic premise:
I have an 89 EMA and a 144 EMA which define the trend for me.
I also have a 5 EMA and a 13 EMA which give me buy and sell signals.
The goal in this study is to only trade with the trend, so basicly when the 144 EMA is above the 89 EMA only short signals will be generated by the 5 and 13 EMA crossovers. When the 144 EMA is below the 89 EMA only long signals will be given by the 5 and 13 EMA crossover.
Set 1 = Check to see that 144 EMA has been generated
Set 2 = Check to see if 144 EMA is above 89 EMA
Set 3 = Check to see if 13 EMA is above 5 EMA, if yes short and sell long
Set 4 = Check to see if 144 EMA is below 89 EMA
Set 5 = Check to see if 13 EMA is below 5 EMA, if yes go long and cover short
Now... I thought I knew what I was doing. I've atached the .efs script I've been working on but it only makes 1 or 2 trades for the testing period and when I look at the chart (60 min EUR A0-FX), there are many many more. Help!
I have an 89 EMA and a 144 EMA which define the trend for me.
I also have a 5 EMA and a 13 EMA which give me buy and sell signals.
The goal in this study is to only trade with the trend, so basicly when the 144 EMA is above the 89 EMA only short signals will be generated by the 5 and 13 EMA crossovers. When the 144 EMA is below the 89 EMA only long signals will be given by the 5 and 13 EMA crossover.
Set 1 = Check to see that 144 EMA has been generated
Set 2 = Check to see if 144 EMA is above 89 EMA
Set 3 = Check to see if 13 EMA is above 5 EMA, if yes short and sell long
Set 4 = Check to see if 144 EMA is below 89 EMA
Set 5 = Check to see if 13 EMA is below 5 EMA, if yes go long and cover short
Now... I thought I knew what I was doing. I've atached the .efs script I've been working on but it only makes 1 or 2 trades for the testing period and when I look at the chart (60 min EUR A0-FX), there are many many more. Help!
PHP Code:
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vEMA5_of_HLC3 = new MAStudy(5, 0, "HLC/3", MAStudy.EXPONENTIAL);
var vEMA13_of_HLC3 = new MAStudy(13, 0, "HLC/3", MAStudy.EXPONENTIAL);
var vEMA89_of_HL2 = new MAStudy(89, 0, "HL/2", MAStudy.EXPONENTIAL);
var vEMA144_of_HL2_2 = new MAStudy(144, 0, "HL/2", MAStudy.EXPONENTIAL);
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("MA Xover Trend Study");
setCursorLabelName("EMA 5 -1", 0);
setCursorLabelName("EMA 13", 1);
setCursorLabelName("EMA 89", 2);
setCursorLabelName("EMA 144", 3);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarStyle(PS_SOLID, 2);
setDefaultBarStyle(PS_SOLID, 3);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.yellow, 2);
setDefaultBarFgColor(Color.white, 3);
setDefaultBarThickness(2, 0);
setDefaultBarThickness(2, 1);
setDefaultBarThickness(2, 2);
setDefaultBarThickness(2, 3);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
setPlotType(PLOTTYPE_LINE, 2);
setPlotType(PLOTTYPE_LINE, 3);
//}}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 (
vEMA144_of_HL2_2.getValue(MAStudy.MA) == null
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
Strategy.isLong() == false &&
vEMA89_of_HL2.getValue(MAStudy.MA, -1) < vEMA144_of_HL2_2.getValue(MAStudy.MA, -1) &&
vEMA89_of_HL2.getValue(MAStudy.MA) > vEMA144_of_HL2_2.getValue(MAStudy.MA)
) onAction2()
//}}EFSWizard_Expression_2
//{{EFSWizard_Expression_3
else if (
Strategy.isLong() == false &&
vEMA5_of_HLC3.getValue(MAStudy.MA, -1) < vEMA13_of_HLC3.getValue(MAStudy.MA, -1) &&
vEMA5_of_HLC3.getValue(MAStudy.MA) > vEMA13_of_HLC3.getValue(MAStudy.MA)
) onAction3()
//}}EFSWizard_Expression_3
//{{EFSWizard_Expression_4
else if (
Strategy.isShort() == false &&
vEMA89_of_HL2.getValue(MAStudy.MA, -1) > vEMA144_of_HL2_2.getValue(MAStudy.MA, -1) &&
vEMA89_of_HL2.getValue(MAStudy.MA) < vEMA144_of_HL2_2.getValue(MAStudy.MA)
) onAction4()
//}}EFSWizard_Expression_4
//{{EFSWizard_Expression_5
else if (
Strategy.isShort() == false &&
vEMA5_of_HLC3.getValue(MAStudy.MA, -1) > vEMA13_of_HLC3.getValue(MAStudy.MA, -1) &&
vEMA5_of_HLC3.getValue(MAStudy.MA) < vEMA13_of_HLC3.getValue(MAStudy.MA)
) onAction5();
//}}EFSWizard_Expression_5
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return new Array(
vEMA5_of_HLC3.getValue(MAStudy.MA),
vEMA13_of_HLC3.getValue(MAStudy.MA),
vEMA89_of_HL2.getValue(MAStudy.MA),
vEMA144_of_HL2_2.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_Action_2
function onAction2() {
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//{{EFSWizard_Action_3
function onAction3() {
Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
Strategy.doSell("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 3;
}
//}}EFSWizard_Action_3
//{{EFSWizard_Action_4
function onAction4() {
vLastAlert = 4;
}
//}}EFSWizard_Action_4
//{{EFSWizard_Action_5
function onAction5() {
Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
Strategy.doCover("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 5;
}
//}}EFSWizard_Action_5
//}}EFSWizard_Actions
Comment