File Name: MAandDMIStrategy.efs
Description:
Combining DMI And Moving Average For A EUR/USD Trading System, by Rombout Kerstens
Formula Parameters:
MA Length : 30
DMI Length : 14
Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.
Download File:
MAandDMIStrategy.efs
EFS Code:
Description:
Combining DMI And Moving Average For A EUR/USD Trading System, by Rombout Kerstens
Formula Parameters:
MA Length : 30
DMI Length : 14
Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.
Download File:
MAandDMIStrategy.efs
EFS Code:
PHP Code:
/*********************************
Provided By:
eSignal (Copyright c eSignal), a division of Interactive Data
Corporation. 2009. All rights reserved. This sample eSignal
Formula Script (EFS) is for educational purposes only and may be
modified and saved under a new file name. eSignal is not responsible
for the functionality once modified. eSignal reserves the right
to modify and overwrite this EFS file with each new release.
Description:
Combining DMI And Moving Average For A EUR/USD Trading System, by Rombout Kerstens
Version: 1.0 06/08/2009
Formula Parameters: Default:
MA Length 30
DMI Length 14
Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit [url]www.traders.com.[/url]
**********************************/
var fpArray = new Array();
var bInit = false;
var bVersion = null;
function preMain() {
setPriceStudy(false);
setShowCursorLabel(true);
setShowTitleParameters(false);
setStudyTitle("MA and MDI Strategy");
setColorPriceBars(true);
setPlotType(PLOTTYPE_LINE);
setDefaultBarThickness(2, 0);
setDefaultBarFgColor(Color.green, 0);
setCursorLabelName("DMI Plus", 0);
setPlotType(PLOTTYPE_LINE);
setDefaultBarThickness(2, 1);
setDefaultBarFgColor(Color.red, 1);
setCursorLabelName("DMI Minus", 1);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("Length_MA", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("MA Length");
setLowerLimit(1);
setDefault(30);
}
fpArray[x] = new FunctionParameter("Length_DMI", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("DMI Length");
setLowerLimit(1);
setDefault(14);
}
}
var xPDI = null;
var xNDI = null;
var xMA = null;
var xClose = null;
function main(Length_MA, Length_DMI) {
var nBarState = getBarState();
var bMDILong = false;
var bMDIShort = false;
var bMALong = false;
var bMAShort = false;
var nPDI = 0;
var nNDI = 0;
var nMA = 0;
var nPDI_1 = 0;
var nNDI_1 = 0;
var nMA_1 = 0;
if (bVersion == null) bVersion = verify();
if (bVersion == false) return;
if (getCurrentBarIndex() == 0) return;
setPriceBarColor(Color.black);
if (nBarState == BARSTATE_ALLBARS) {
if (Length_MA == null) Length_MA = 30;
if (Length_DMI == null) Length_DMI = 14;
}
if (bInit == false) {
xMA = sma(Length_MA);
xPDI = pdi(Length_DMI, 1);
xNDI = ndi(Length_DMI, 1);
xClose = close();
bInit = true;
}
nPDI = xPDI.getValue(0);
nNDI = xNDI.getValue(0);
nMA = xMA.getValue(0);
nPDI_1 = xPDI.getValue(-1);
nNDI_1 = xNDI.getValue(-1);
nMA_1 = xMA.getValue(-1);
if (nMA_1 == null || nPDI_1 == null) return;
if (nPDI > nNDI && nPDI_1 < nNDI_1) {
bMDILong = true;
bMDIShort = false;
}
if (nPDI < nNDI && nPDI_1 > nNDI_1) {
bMDILong = false;
bMDIShort = true;
}
if (xClose.getValue(0) > nMA && xClose.getValue(-1) < nMA_1) {
bMALong = true;
bMAShort = false;
}
if (xClose.getValue(0) < nMA && xClose.getValue(-1) > nMA_1) {
bMALong = false;
bMAShort = true;
}
if (bMDILong && bMALong && !Strategy.isLong()) {
drawTextRelative(0, TopRow1, " LONG", Color.white, Color.green, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5);
Strategy.doLong("Enyry Long", Strategy.CLOSE, Strategy.THISBAR);
}
if (bMDIShort && bMAShort && Strategy.isLong()) {
drawTextRelative(0, BottomRow1, " EXIT", Color.white, Color.red, Text.PRESET|Text.CENTER|Text.FRAME, "Arial Black", 10, "b"+(getCurrentBarCount()), -5);
Strategy.doSell("Exit Long", Strategy.CLOSE, Strategy.THISBAR);
}
if(Strategy.isLong())
setBarBgColor(Color.lime, 0, 0, 100);
return new Array(nPDI, nNDI);
}
function verify() {
var b = false;
if (getBuildNumber() < 779) {
drawTextAbsolute(5, 35, "This study requires version 8.0 or later.",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
null, 13, "error");
drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
null, 13, "upgrade");
return b;
} else {
b = true;
}
return b;
}