File Name: BasicDonchianSystem.efs
Description:
The Degree Of Complexity by Oscar G. Cagigas
Formula Parameters:
BasicDonchianSystem.efs
Len1: 40
Len2: 15
Long Color: lime
Short Color: red
Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.
Download File:
BasicDonchianSystem.efs
BasicDonchianSystem.efs
EFS Code:
Description:
The Degree Of Complexity by Oscar G. Cagigas
Formula Parameters:
BasicDonchianSystem.efs
Len1: 40
Len2: 15
Long Color: lime
Short Color: red
Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.
Download File:
BasicDonchianSystem.efs
BasicDonchianSystem.efs
EFS Code:
PHP Code:
/*********************************
Provided By:
Interactive Data Corporation (Copyright В© 2013)
All rights reserved. This sample eSignal Formula Script (EFS)
is for educational purposes only. Interactive Data Corporation
reserves the right to modify and overwrite this EFS file with
each new release.
Description:
The Degree Of Complexity by Oscar G. Cagigas
Formula Parameters: Default:
Len1 40
Len2 15
Long Color lime
Short Color red
Version: 1.00 12/05/2013
Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.
**********************************/
var fpArray = new Array();
function preMain()
{
setStudyTitle("BasicDonchianSystem");
setPriceStudy(true);
var x = 0;
fpArray[x] = new FunctionParameter("fpLen1", FunctionParameter.NUMBER);
with(fpArray[x++])
{
setName("Len1");
setLowerLimit(20);
setUpperLimit(40);
setDefault(40);
}
fpArray[x] = new FunctionParameter("fpLen2", FunctionParameter.NUMBER);
with(fpArray[x++])
{
setName("Len2");
setLowerLimit(5);
setUpperLimit(30);
setDefault(15);
}
fpArray[x] = new FunctionParameter("gLongColor", FunctionParameter.COLOR);
with(fpArray[x++])
{
setName("Long Color");
setDefault(Color.lime);
}
fpArray[x] = new FunctionParameter("gShortColor", FunctionParameter.COLOR);
with(fpArray[x++])
{
setName("Short Color");
setDefault(Color.red);
}
}
var bInit = false;
var bVersion = null;
var xHHV1 = null;
var xLLV1 = null;
var xHHV2 = null;
var xLLV2 = null;
var xHigh = null;
var xLow = null;
var xOpen = null;
function main(fpLen1,fpLen2,gLongColor,gShortColor)
{
if (bVersion == null) bVersion = verify();
if (bVersion == false) return;
if (!bInit)
{
xHigh = high();
xLow = low();
xOpen = open();
xHHV1 = hhv(fpLen1, xHigh);
xLLV1 = llv(fpLen1, xLow);
xHHV2 = hhv(fpLen2, xHigh);
xLLV2 = llv(fpLen2, xLow);
bInit = true;
}
var nBuyStop = xHHV1.getValue(-1);
var nSellStop = xLLV2.getValue(-1);
var nShortStop = xLLV1.getValue(-1);
var nCoverStop = xHHV2.getValue(-1);
var nHigh = xHigh.getValue(0);
var nLow = xLow.getValue(0);
var nOpen = xOpen.getValue(0);
if (nBuyStop == null || nSellStop == null || nShortStop == null || nCoverStop == null || nHigh == null || nLow == null || nOpen == null)
return;
nPrice=null;
if (getCurrentBarIndex() != 0)
{
// Entry Strategy
if (!Strategy.isInTrade())
{
//LONG ENTRY
if (nHigh > nBuyStop)
{
Strategy.doLong("Enter Long", Strategy.CLOSE, Strategy.THISBAR);
drawTextRelative(0, BelowBar2, "Long", Color.black, gLongColor, Text.PRESET, null, null);
}
else
{
//SHORT ENTRY
if (nLow < nShortStop)
{
Strategy.doShort("Enter Short", Strategy.CLOSE, Strategy.THISBAR);
drawTextRelative(0, AboveBar2, "Short", Color.black, gShortColor, Text.PRESET, null, null);
}
}
}
// Exit Strategy
if (Strategy.isInTrade())
{
//EXIT
if ((nLow < nSellStop) && Strategy.isLong())
{
Strategy.doSell("Exit", Strategy.CLOSE, Strategy.THISBAR);
drawTextRelative(0, AboveBar2, "Exit", Color.black, gShortColor, Text.PRESET, null, null);
}
else
{
//COVER
if ((nHigh > nCoverStop) && Strategy.isShort())
{
Strategy.doCover("Cover", Strategy.CLOSE, Strategy.THISBAR);
drawTextRelative(0, BelowBar2, "Cover", Color.black, gLongColor, Text.PRESET, null, null);
}
}
}
}
return;
}
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;
}