Wed05222013

Last update12:00:00 AM

## eSIGNAL: SEPTEMBER 2012

For this month’s Traders’ Tip, we’ve provided the formula MultiPairIndicator.efs based on Vladimir Vladimirovich Voznjuk’s article in this issue, “Developing A Multilevel Strategy.”

Our multipair indicator study presented here contains formula parameters to set the two symbols to use for the pair, an option to use the one-way pair calculation, the upper band value, lower band value, the signal method (either levels or zero line), and the buy/sell signal colors, which may be configured through the Edit Chart window. This indicator will draw up and down arrows at the top and bottom in the indicator pane based on the signals as they occur.

To discuss this study or download a complete copy of the formula code, please visit the EFS library discussion board forum under the forums link from the support menu at www.esignal.com or visit our EFS KnowledgeBase at www.esignal.com/support/kb/efs/. The eSignal formula scripts (EFS) are also available for copying & pasting below.

```/*********************************
Provided By:
eSignal (Copyright c eSignal), a division of Interactive Data
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:
Pair Trading. Developing A Multi-Level Strategy by Vladimir Vladimirovich Voznjuk
Version:            1.00  16/07/2012
Formula Symbol1eters:                         Default:
Symbol 1                                  6J #F
Symbol 2                                  6E #F
One-way Pair                              false
Lower Band                                -0.01
Upper Band                                0.01
Signal Method                             Levels
Sell Color                                red
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("MultiPair Indicator");
setIntervalsBackfill(true);
var x = 0;
fpArray[x] = new FunctionParameter("gSymbol1", FunctionParameter.STRING);
with(fpArray[x++])
{
setName("Symbol 1");
setDefault("6J #F");
}
fpArray[x] = new FunctionParameter("gSymbol2", FunctionParameter.STRING);
with(fpArray[x++])
{
setName("Symbol 2");
setDefault("6E #F");
}
fpArray[x] = new FunctionParameter("gOneWay", FunctionParameter.BOOLEAN);
with(fpArray[x++])
{
setName("One-way Pair");
setDefault(false);
}
fpArray[x] = new FunctionParameter("gLower", FunctionParameter.NUMBER);
with(fpArray[x++])
{
setName("Lower Band");
setDefault(-0.01);
}
fpArray[x] = new FunctionParameter("gUpper", FunctionParameter.NUMBER);
with(fpArray[x++])
{
setName("Upper Band");
setDefault(0.01);
}
fpArray[x] = new FunctionParameter("gMethod", FunctionParameter.STRING);
with(fpArray[x++])
{
setName("Signal Method");
setDefault("Levels");
}
fpArray[x] = new FunctionParameter("gBuyColor", FunctionParameter.COLOR);
with(fpArray[x++])
{
setDefault(Color.blue);
}
fpArray[x] = new FunctionParameter("gSellColor", FunctionParameter.COLOR);
with(fpArray[x++])
{
setName("Sell Color");
setDefault(Color.red);
}
}
var bInit = false;
var bVersion = null;
var xSymbol2Open = null;
var xSymbol2Close = null;
var xSymbol1Open = null;
var xSymbol1Close = null;
var vInterval = null;
function main(gSymbol1, gSymbol2, gOneWay, gLower, gUpper, gMethod,gBuyColor,gSellColor)
{
if (bVersion == null) bVersion = verify();
if (bVersion == false) return;
if (!bInit)
{
vInterval = getInterval();
xSymbol2Open = open(sym(gSymbol2+","+vInterval));
xSymbol2Close = close(sym(gSymbol2+","+vInterval));
xSymbol1Open = open(sym(gSymbol1+","+vInterval));
xSymbol1Close = close(sym(gSymbol1+","+vInterval));
bInit = true;
}
var vSymbol2Open_0 = xSymbol2Open.getValue(0);
var vSymbol2Open_1 = xSymbol2Open.getValue(-1);
var vSymbol2Close_0 = xSymbol2Close.getValue(0);
var vSymbol2Close_1 = xSymbol2Close.getValue(-1);
var vSymbol1Open_0 = xSymbol1Open.getValue(0);
var vSymbol1Open_1 = xSymbol1Open.getValue(-1);
var vSymbol1Close_0 = xSymbol1Close.getValue(0);
var vSymbol1Close_1 = xSymbol1Close.getValue(-1);
if (vSymbol2Open_1 == null || vSymbol2Close_1 == null || vSymbol1Open_1 == null || vSymbol1Close_1 == null)
return;
var vRes_0 = 0;
var vRes_1 = 0;
if (gOneWay)
{
vRes_0 = (vSymbol2Close_0 - vSymbol2Open_0)+(vSymbol1Close_0 - vSymbol1Open_0);
vRes_1 = (vSymbol2Close_1 - vSymbol2Open_1)+(vSymbol1Close_1 - vSymbol1Open_1);
}
else
{
vRes_0 = (vSymbol2Close_0 - vSymbol2Open_0)-(vSymbol1Close_0 - vSymbol1Open_0);
vRes_1 = (vSymbol2Close_1 - vSymbol2Open_1)-(vSymbol1Close_1 - vSymbol1Open_1);
}
var nBarsCount = getCurrentBarCount();
if (gMethod == "Levels")
{
if (vRes_0>gUpper && vRes_1<gUpper)
{
drawShapeRelative(0, TopRow2  , Shape.DOWNARROW, null, gSellColor, Shape.PRESET,"LDn"+nBarsCount);
}
else
{
removeShape("LDn"+nBarsCount);
}
if (vRes_0<gLower && vRes_1>gLower)
{
drawShapeRelative(0, BottomRow2  , Shape.UPARROW, null, gBuyColor, Shape.PRESET,"LUp"+nBarsCount);
}
else
{
removeShape("LUp"+nBarsCount);
}
}
if (gMethod == "Zero line")
{
if (vRes_1<0 && vRes_0>0)
{
drawShapeRelative(0, BottomRow2  , Shape.UPARROW, null, gBuyColor, Shape.PRESET,"ZUp"+nBarsCount);
}
else
{
removeShape("ZUp"+nBarsCount);
}
if (vRes_1>0 && vRes_0<0)
{
drawShapeRelative(0, TopRow2  , Shape.DOWNARROW, null, gSellColor, Shape.PRESET,"ZDn"+nBarsCount);
}
else
{
removeShape("ZDn"+nBarsCount);
}
}
return vRes_0;
}
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");
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
return b;
} else {
b = true;
}
return b;
}```

A sample chart is shown in Figure 1.

FIGURE 1: eSIGNAL, MULTIPAIR INDICATOR STUDY

—Jason Keck
eSignal, an Interactive Data company
800 779-6555, www.eSignal.com

To read the entire issue click here and subscribe today!

DEPARTMENTS: Advertising | Editorial | Circulation | Employment | Contact Us | BY PHONE: (206) 938-0570