File Name: Confluence.efs
Description:
Confluence
Formula Parameters:
Price Data To Use : Close
Harmonic : 10
Notes:
This is modified version of Dale Legan's "Confluence" indicator written by Gary Fritz.
Download File:
Confluence.efs
EFS Code:
Description:
Confluence
Formula Parameters:
Price Data To Use : Close
Harmonic : 10
Notes:
This is modified version of Dale Legan's "Confluence" indicator written by Gary Fritz.
Download File:
Confluence.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:
Confluence
Version: 1.0 04/01/2009
Formula Parameters: Default:
Price Data To Use Close
Harmonic 10
Notes:
This is modified version of Dale Legan's "Confluence" indicator written by Gary Fritz.
**********************************/
var fpArray = new Array();
var bInit = false;
function preMain() {
setStudyTitle("Confluence");
setCursorLabelName("Bull", 0);
setCursorLabelName("Bear", 1);
setCursorLabelName("ZERO", 2);
setCursorLabelName("Grey", 3);
setShowCursorLabel(true);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.green, 2);
setDefaultBarFgColor(Color.grey, 3);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setPlotType(PLOTTYPE_HISTOGRAM, 1);
setPlotType(PLOTTYPE_HISTOGRAM, 2);
setPlotType(PLOTTYPE_HISTOGRAM, 3);
setDefaultBarThickness(2, 0);
setDefaultBarThickness(2, 1);
setDefaultBarThickness(2, 2);
setDefaultBarThickness(2, 3);
setStudyMax(11);
setStudyMin( - 11);
var x = 0;
fpArray[x] = new FunctionParameter("Harmonic", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(1);
setDefault(10);
}
fpArray[x] = new FunctionParameter("sPrice", FunctionParameter.STRING);
with(fpArray[x++]) {
setName("Price Data To Use");
addOption("open");
addOption("high");
addOption("low");
addOption("close");
addOption("hl2");
addOption("hlc3");
addOption("ohlc4");
setDefault("close");
}
}
var STL = 0;
var ITL = 0;
var LTL = 0;
var HOFF = 0;
var SOFF = 0;
var IOFF = 0;
var LTOFF = 0;
var ErrNum = 0;
var momNum = 0;
var TCNum = 0;
var xPrice = null;
var xHavg = null;
var xSavg = null;
var xIavg = null;
var xLavg = null;
var xvalue2 = null;
var xvalue3 = null;
var xvalue12 = null;
var xmomsig = null;
var xH2 = null;
var xS2 = null;
var xI2 = null;
var xL2 = null;
var xvalue5 = null;
var xvalue6 = null;
var xvalue7 = null;
var xvalue13 = null;
var xmom = null;
var xSum = null;
var xErr = null;
var xErrSig = null;
var xErrSum = null;
var xvalue70 = null;
var xvalue71 = null;
function main(sPrice, Harmonic) {
var nBarState = getBarState();
if (nBarState == BARSTATE_ALLBARS) {
if (sPrice == null) sPrice = "close";
if (Harmonic == null) Harmonic = 10;
}
if (bInit == false) {
STL = Math.round((Harmonic * 2) - 1 - 0.5);
ITL = Math.round((STL * 2) - 1 - 0.5);
LTL = Math.round((ITL * 2) - 1 - 0.5);
HOFF = Math.round(Harmonic / 2 - 0.5);
SOFF = Math.round(STL / 2 - 0.5);
IOFF = Math.round(ITL / 2 - 0.5);
xPrice = eval(sPrice)();
xHavg = sma(Harmonic, xPrice);
xSavg = sma(STL, xPrice);
xIavg = sma(ITL, xPrice);
xLavg = sma(LTL, xPrice);
xvalue2 = efsInternal("Calc_Values2", SOFF, HOFF, IOFF, xHavg, xSavg, xIavg, xLavg);
xvalue3 = getSeries(xvalue2, 1);
xvalue12 = getSeries(xvalue2, 2);
xmomsig = efsInternal("Calc_MOMSig", xvalue2, xvalue3, xvalue12);
xvalue5 = efsInternal("Calc_Values", Harmonic, STL, ITL, LTL, xHavg, xSavg, xIavg, xLavg,
sma(Harmonic - 1, xPrice), sma(STL - 1, xPrice), sma(ITL - 1, xPrice), sma(LTL - 1, xPrice));
xvalue6 = getSeries(xvalue5, 1);
xvalue7 = getSeries(xvalue5, 2);
xvalue13 = getSeries(xvalue5, 3);
xmom = efsInternal("Calc_xMOM", HOFF, SOFF, IOFF, xvalue5, xvalue6, xvalue7, xvalue13);
xSum = efsInternal("Calc_Sum_Err", xvalue5, xvalue6, xvalue7, xHavg, xSavg, xIavg);
xErr = getSeries(xSum, 1);
xErrSum = efsInternal("Calc_ErrSum", SOFF, xSum, xErr, xHavg);
xErrSig = sma(SOFF, xErrSum);
xvalue70 = efsInternal("Calc_Value70", xvalue5, xvalue13);
xvalue71 = sma(Harmonic, xvalue70);
bInit = true;
}
if (xvalue71.getValue(0) == null) return;
var nErrSum = xErrSum.getValue(0);
var nErrSum1 = xErrSum.getValue( - 1);
var nErrSig = xErrSig.getValue(0);
var nmom = xmom.getValue(0);
var nmom1 = xmom.getValue( - 1);
var nmomsig = xmomsig.getValue(0);
var nvalue70 = xvalue70.getValue(0);
var nvalue701 = xvalue70.getValue( - 1);
var nvalue71 = xvalue71.getValue(0);
if (nErrSum > 0) {
if ((nErrSum < nErrSum1) && (nErrSum < nErrSig)) ErrNum = 1;
if ((nErrSum < nErrSum1) && (nErrSum > nErrSig)) ErrNum = 2;
if ((nErrSum > nErrSum1) && (nErrSum < nErrSig)) ErrNum = 2;
if ((nErrSum > nErrSum1) && (nErrSum > nErrSig)) ErrNum = 3;
}
if (nErrSum < 0) {
if ((nErrSum > nErrSum1) && (nErrSum > nErrSig)) ErrNum = -1;
if ((nErrSum < nErrSum1) && (nErrSum > nErrSig)) ErrNum = -2;
if ((nErrSum > nErrSum1) && (nErrSum < nErrSig)) ErrNum = -2;
if ((nErrSum < nErrSum1) && (nErrSum < nErrSig)) ErrNum = -3;
}
if (nmom > 0) {
if ((nmom < nmom1) && (nmom < nmomsig)) momNum = 1;
if ((nmom < nmom1) && (nmom > nmomsig)) momNum = 2;
if ((nmom > nmom1) && (nmom < nmomsig)) momNum = 2;
if ((nmom > nmom1) && (nmom > nmomsig)) momNum = 3;
}
if (nmom < 0) {
if ((nmom > nmom1) && (nmom > nmomsig)) momNum = -1;
if ((nmom < nmom1) && (nmom > nmomsig)) momNum = -2;
if ((nmom > nmom1) && (nmom < nmomsig)) momNum = -2;
if ((nmom < nmom1) && (nmom < nmomsig)) momNum = -3;
}
if (nvalue70 > 0) {
if ((nvalue70 < nvalue701) && (nvalue70 < nvalue71)) TCNum = 1;
if ((nvalue70 < nvalue701) && (nvalue70 > nvalue71)) TCNum = 2;
if ((nvalue70 > nvalue701) && (nvalue70 < nvalue71)) TCNum = 2;
if ((nvalue70 > nvalue701) && (nvalue70 > nvalue71)) TCNum = 3;
}
if (nvalue70 < 0) {
if ((nvalue70 > nvalue701) && (nvalue70 > nvalue71)) TCNum = -1;
if ((nvalue70 < nvalue701) && (nvalue70 > nvalue71)) TCNum = -2;
if ((nvalue70 > nvalue701) && (nvalue70 < nvalue71)) TCNum = -2;
if ((nvalue70 < nvalue701) && (nvalue70 < nvalue71)) TCNum = -3;
}
var value42 = ErrNum + momNum + TCNum;
var Confluence = 0.0;
if ((value42 > 0) && (nvalue70 > 0)) Confluence = value42;
if ((value42 < 0) && (nvalue70 < 0)) Confluence = value42;
if (((value42 > 0) && (nvalue70 < 0)) || ((value42 < 0) && (nvalue70 > 0))) Confluence = value42 / 10;
var Res1 = null;
var Res2 = null;
var Res3 = null;
var Res4 = null;
if (Confluence >= 1) Res1 = Confluence;
if (Confluence <= -1) Res2 = Confluence;
if (Confluence == 0) Res3 = 0;
else if ((Confluence > -1) && (Confluence < 1)) Res4 = 10 * Confluence;
return new Array(Res1, Res2, Res3, Res4);
}
function Calc_MOMSig(xvalue2, xvalue3, xvalue12) {
var nRes = 0;
nRes = xvalue2.getValue(0) + xvalue3.getValue(0) + xvalue12.getValue(0);
if (nRes == null) {
return;
}
return nRes;
}
var bSecondInit = false;
var xLavgOHLC = null;
function Calc_Values(Harmonic, STL, ITL, LTL, xHavg, xSavg, xIavg, xLavg, xH2, xS2, xI2, xL2) {
if (bSecondInit == false) {
xLavgOHLC = sma(LTL - 1, ohlc4());
bSecondInit = true;
}
var DerivH = (xHavg.getValue(0) * 2) - xHavg.getValue( - 1);
var DerivS = (xSavg.getValue(0) * 2) - xSavg.getValue( - 1);
var DerivI = (xIavg.getValue(0) * 2) - xIavg.getValue( - 1);
var DerivL = (xLavg.getValue(0) * 2) - xLavg.getValue( - 1);
var SumDH = Harmonic * DerivH;
var SumDS = STL * DerivS;
var SumDI = ITL * DerivI;
var SumDL = LTL * DerivL;
var LengH = Harmonic - 1;
var LengS = STL - 1;
var LengI = ITL - 1;
var LengL = LTL - 1;
var nH2 = xH2.getValue(0);
var nS2 = xS2.getValue(0);
var nI2 = xI2.getValue(0);
var N1H = nH2 * LengH;
var N1S = nS2 * LengS;
var N1I = nI2 * LengI;
var N1L = xL2.getValue(0) * LengL;
var DRH = SumDH - N1H;
var DRS = SumDS - N1S;
var DRI = SumDI - N1I;
var DRL = SumDL - N1L;
var SumH = nH2 * (Harmonic - 1);
var SumS = nS2 * (STL - 1);
var SumI = nI2 * (ITL - 1);
var SumL = xLavgOHLC.getValue(0) * (LTL - 1);
var value5 = (SumH + DRH) / Harmonic;
var value6 = (SumS + DRS) / STL;
var value7 = (SumI + DRI) / ITL;
var value13 = (SumL + DRL) / LTL;
if (value5 == null || value6 == null || value7 == null || value13 == null) return;
return new Array(value5, value6, value7, value13);
}
function Calc_xMOM(HOFF, SOFF, IOFF, xvalue5, xvalue6, xvalue7, xvalue13) {
var value9 = xvalue6.getValue(0) - xvalue5.getValue( - HOFF);
var value10 = xvalue7.getValue(0) - xvalue6.getValue( - SOFF);
var value14 = xvalue13.getValue(0) - xvalue7.getValue( - IOFF);
var nRes = value9 + value10 + value14;
if (nRes == null) return;
return nRes;
}
function Calc_Sum_Err(xvalue5, xvalue6, xvalue7, xHavg, xSavg, xIavg) {
var nvalue5 = xvalue5.getValue(0);
var nHavg = xHavg.getValue(0);
var nvalue6 = xvalue6.getValue(0);
var nSavg = xSavg.getValue(0);
var nvalue7 = xvalue7.getValue(0);
var nIavg = xIavg.getValue(0);
var HT = Math.sin(nvalue5 * 2 * Math.PI / 360) + Math.cos(nvalue5 * 2 * Math.PI / 360);
var HTA = Math.sin(nHavg * 2 * Math.PI / 360) + Math.cos(nHavg * 2 * Math.PI / 360);
var ST = Math.sin(nvalue6 * 2 * Math.PI / 360) + Math.cos(nvalue6 * 2 * Math.PI / 360);
var STA = Math.sin(nSavg * 2 * Math.PI / 360) + Math.cos(nSavg * 2 * Math.PI / 360);
var IT = Math.sin(nvalue7 * 2 * Math.PI / 360) + Math.cos(nvalue7 * 2 * Math.PI / 360);
var ITA = Math.sin(nIavg * 2 * Math.PI / 360) + Math.cos(nIavg * 2 * Math.PI / 360);
var Sum = HT + ST + IT;
var Err = HTA + STA + ITA;
if (Sum == null || Err == null) return;
return new Array(Sum, Err);
}
function Calc_ErrSum(SOFF, xSum, xErr, xHavg) {
var nSum = xSum.getValue(0);
var nHavg = xHavg.getValue(0);
var nSumSOFF = xSum.getValue( - SOFF);
var nHavgSOFF = xHavg.getValue( - SOFF);
var Condition2 = (((nSum > nSumSOFF) && (nHavg < nHavgSOFF)) || ((nSum < nSumSOFF) && (nHavg > nHavgSOFF)));
var Phase = 1;
if (Condition2) Phase = -1;
var ErrSum = (nSum - xErr.getValue(0)) * Phase;
if (ErrSum == null) return;
return ErrSum;
}
function Calc_Value70(xvalue5, xvalue13) {
var value70 = xvalue5.getValue(0) - xvalue13.getValue(0);
if (value70 == null) return;
return value70;
}
function Calc_Values2(SOFF, HOFF, IOFF, xHavg, xSavg, xIavg, xLavg) {
var value2 = xSavg.getValue(0) - xHavg.getValue( - HOFF);
var value3 = xIavg.getValue(0) - xSavg.getValue( - SOFF);
var value12 = xLavg.getValue(0) - xIavg.getValue( - IOFF);
if (value2 == null || value3 == null || value12 == null) return;
return new Array(value2, value3, value12)
}