2012 Jan: Reversing MACD by Johnny Dough

ICE Data Services -


ReversingMACD.efs, ReversingMACD_Indicator.efs  EFSLibrary - Discussion Board
  

File Name: ReversingMACD.efs, ReversingMACD_Indicator.efs

Description:
Reversing MACD by Johnny Dough


Formula Parameters:

ReversingMACD.efs
Price Source: Close
Period Fast: 12
Period Slow: 26
Period Signal: 9
Plot Chart: PMACD

ReversingMACD_Indicator.efs
Price Source: Close
Period Fast: 12
Period Slow: 26
Period Signal: 9
Plot Chart: PMACD
Bollinger Bands Period: 10




Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.

Download File:
ReversingMACD.efs
ReversingMACD_Indicator.efs

ReversingMACD.efs, ReversingMACD_Indicator.efs



EFS Code:

ReversingMACD.efs

/*********************************Provided By:      Interactive Data Corporation (Copyright ?? 2010)     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:            Reversing MACD	Version:            1.00  14/11/2011Formula Parameters:                     Default:Price Source                            ClosePeriod Fast                             12Period Slow                             26Period Signal                           9Plot Chart                              PMACDNotes:    The related article is copyrighted material. If you are not a subscriber    of Stocks & Commodities, please visit www.traders.com.**********************************/// predefined constantsvar BBPERIOD = 10;var BBSTDEV = 1;var fpArray = new Array();function preMain(){          setPriceStudy(true);    setStudyTitle("Reversing MACD");        var x=0;    fpArray[x] = new FunctionParameter("priceSource", FunctionParameter.STRING);    with(fpArray[x++])    {	setName("Price Source");        addOption("Open");        addOption("Close");        addOption("Low");        addOption("High");        addOption("HL/2");        addOption("HLC/3");        addOption("OHLC/4");        setDefault("Close");    }     fpArray[x] = new FunctionParameter("pFast", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("Period Fast");	setLowerLimit(1);        setUpperLimit(24);        setDefault(12);    }        fpArray[x] = new FunctionParameter("pSlow", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("Period Slow");	setLowerLimit(2);        setUpperLimit(52);        setDefault(26);    }        fpArray[x] = new FunctionParameter("pSignal", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("Period Signal");	setLowerLimit(0);        setUpperLimit(18);        setDefault(9);    }        fpArray[x] = new FunctionParameter("pPlotChart", FunctionParameter.STRING);    with(fpArray[x++])    {	setName("Plot Chart");        addOption("PMACD");        addOption("PMACD_HLC");        addOption("PMACD_BB");        addOption("PMACD_MTF");        setDefault("PMACD");          }  }var bInit = false;var bVersion = null;var xSource = null;var xPMACD_0 = null;function main(priceSource, pFast, pSlow, pSignal, pPlotChart){    if (bVersion == null) bVersion = verify();    if (bVersion == false) return;               if(!bInit)    {        switch (priceSource)        {                case 'Open':                    xSource = open();                   break;                case 'Close':                   xSource = close();                   break;                case 'High':                   xSource = high();                   break;                case 'Low':                   xSource = low();                   break;                case 'HL/2':                   xSource = hl2();                   break;                case 'HLC/3':                   xSource = hlc3();                   break;                case 'OHLC/4':                   xSource = ohlc4();                   break;                default : return;        }                xPMACD_0 = efsInternal("PMACDzero", pFast, pSlow, xSource);                setCursorLabelName("PMACDzero", 0);        setDefaultBarThickness(3, 0);    }        var resultArr = null;        switch (pPlotChart)    {        case "PMACD" :            resultArr = calc_PMACD(xSource, pFast, pSlow, pSignal);            break;                case "PMACD_HLC" :            resultArr = calc_PMACD_HLC(pFast, pSlow);             break;                case "PMACD_BB" :            resultArr = calc_PMACD_BB(xSource, pFast, pSlow);            break;                case "PMACD_MTF" :             resultArr = calc_PMACD_MTF(xSource, pFast, pSlow);            break;                default :             bInit = true;            return;    }           var nPMACD_0 = xPMACD_0.getValue(0);    var nSource = xSource.getValue(0);        // PMACD_0 vs price selected    if(nPMACD_0 < nSource)        setDefaultBarFgColor(Color.darkgreen, 0);    else        setDefaultBarFgColor(Color.maroon, 0);        resultArr.unshift(nPMACD_0);        return resultArr;}// calc_PMACDvar xPMACD = null;var xEMA = null;function calc_PMACD(xSource, pFast, pSlow, pSignal){    if(!bInit)    {        xPMACD = efsInternal("PMACDeq", pFast, pSlow, xSource);        xEMA = ema(pSignal, xPMACD);                              setCursorLabelName("PMACDeq", 1);        setCursorLabelName("EMA(PMACDeq)", 2);                setDefaultBarThickness(2, 1);        setDefaultBarThickness(1, 2);                setDefaultBarFgColor(Color.RGB(0, 100, 255) , 1);        setDefaultBarFgColor(Color.RGB(255, 100, 0), 2);                bInit = true;    }    var nPMACD = xPMACD.getValue(0);    var nEMA = xEMA.getValue(0);        return new Array(nPMACD, nEMA);}// calc_PMACD_HLCvar xPMACD_H = null;var xPMACD_C = null;var xPMACD_L = null;function calc_PMACD_HLC(pFast, pSlow){    if(!bInit)    {        xPMACD_H = efsInternal("PMACDeq", pFast, pSlow, high());        xPMACD_C = efsInternal("PMACDeq", pFast, pSlow, close());        xPMACD_L = efsInternal("PMACDeq", pFast, pSlow, low());                setCursorLabelName("PMACDeq(High)", 1);        setCursorLabelName("PMACDeq(Close)", 2);        setCursorLabelName("PMACDeq(Low)", 3);                setDefaultBarThickness(1, 1);        setDefaultBarThickness(2, 2);        setDefaultBarThickness(1, 3);                setDefaultBarFgColor(Color.lime, 1);        setDefaultBarFgColor(Color.RGB(0, 100, 255), 2);        setDefaultBarFgColor(Color.RGB(255, 100, 0), 3);                 bInit = true;    }        var nPMACD_H = xPMACD_H.getValue(0);    var nPMACD_C = xPMACD_C.getValue(0);    var nPMACD_L = xPMACD_L.getValue(0);        return new Array(nPMACD_H, nPMACD_C, nPMACD_L);}// calc_PMACD_BBvar xPMACD_BB = null;var xPMACD_bTop = null;var xPMACD_bBot = null;function calc_PMACD_BB(xSource, pFast, pSlow){    if(!bInit)    {        xPMACD_BB = efsInternal("PMACDeq", pFast, pSlow, xSource);        xPMACD_bTop = upperBB(BBPERIOD, BBSTDEV, xPMACD_BB);        xPMACD_bBot = lowerBB(BBPERIOD, BBSTDEV, xPMACD_BB);                setCursorLabelName("PMACDeq", 1);        setCursorLabelName("BBTop", 2);        setCursorLabelName("BBBot", 3);                setDefaultBarThickness(2, 1);        setDefaultBarThickness(1, 2);        setDefaultBarThickness(1, 3);                setDefaultBarFgColor(Color.RGB(0, 100, 255), 1);        setDefaultBarFgColor(Color.lime, 2);        setDefaultBarFgColor(Color.RGB(255, 100, 0), 3);                 bInit = true;    }    var nPMACD_BB = xPMACD_BB.getValue(0);    var nPMACD_bTop = xPMACD_bTop.getValue(0);    var nPMACD_bBot = xPMACD_bBot.getValue(0);        return new Array(nPMACD_BB, nPMACD_bTop, nPMACD_bBot);}// calc_PMACD_MTFvar xPMACD_MTF = null;var xPMACD_MTF5 = null;var xPMACD_MTF21 = null;function calc_PMACD_MTF(xSource, pFast, pSlow){    if(!bInit)    {        xPMACD_MTF = efsInternal("PMACDeq", pFast, pSlow, xSource);        xPMACD_MTF5 = efsInternal("PMACDeq", 5 * pFast, 5 * pSlow, xSource);        xPMACD_MTF21 = efsInternal("PMACDeq", 21 * pFast, 21 * pSlow, xSource);                setCursorLabelName("PMACDeq", 1);        setCursorLabelName("5*PMACDeq", 2);        setCursorLabelName("21*PMACDeq", 3);                setDefaultBarThickness(2, 1);        setDefaultBarThickness(1, 2);        setDefaultBarThickness(1, 3);                setDefaultBarFgColor(Color.RGB(0, 100, 255), 1);        setDefaultBarFgColor(Color.lime, 2);        setDefaultBarFgColor(Color.RGB(255, 100, 0), 3);                 bInit = true;    }      var nPMACD_MTF = xPMACD_MTF.getValue(0);    var nPMACD_MTF5 = xPMACD_MTF5.getValue(0);    var nPMACD_MTF21 = xPMACD_MTF21.getValue(0);        return new Array(nPMACD_MTF, nPMACD_MTF5, nPMACD_MTF21);   }/*************************************************             SUPPORT FUNCTIONS                    **************************************************/   // PMACDeq - calculates what the next bar price needs to be for the MACD value to be the same.var alphaX_eq = null;var alphaY_eq = null;var xEMAx_eq = null;var xEMAy_eq = null;var PMACDeq_Init = false;function PMACDeq(periodX, periodY, xSeries){        if(!PMACDeq_Init)    {        alphaX_eq = 2 / (1 + periodX);        alphaY_eq = 2 / (1 + periodY);        xEMAx_eq = ema(periodX, xSeries);        xEMAy_eq = ema(periodY, xSeries);                      PMACDeq_Init = true;    }        var nEMAx = xEMAx_eq.getValue(-1);    var nEMAy = xEMAy_eq.getValue(-1);        if (nEMAx == null || nEMAy == null)        return;        var result = (alphaX_eq * nEMAx - alphaY_eq * nEMAy) / (alphaX_eq - alphaY_eq);        return result;}// PMACDLevel - calculates what the price needs to be for the MACD value to be particular constant value.var alphaX_lev = null;var alphaY_lev = null;var xEMAx_lev = null;var xEMAy_lev = null;var PMACDLevel_Init = false;function PMACDLevel(periodX, periodY, level, xSeries){    if(!PMACDLevel_Init)    {        alphaX_lev = 2 / (1 + periodX);        alphaY_lev = 2 / (1 + periodY);        xEMAx_lev = ema(periodX, xSeries);        xEMAy_lev = ema(periodY, xSeries);                PMACDLevel_Init = true;    }        var nEMAx = xEMAx_lev.getValue(-1);    var nEMAy = xEMAy_lev.getValue(-1);        if (nEMAx == null || nEMAy == null)        return;        var result = (level + (1 - alphaY_lev) * nEMAy - (1 - alphaX_lev) * nEMAx) / (alphaX_lev - alphaY_lev);        return result;}// PMACDzerofunction PMACDzero(periodX, periodY, xSeries){    return PMACDLevel(periodX, periodY, 0, xSeries);}// verify versionfunction 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;}


ReversingMACD_Indicator.efs
/*********************************Provided By:      Interactive Data Corporation (Copyright ?? 2010)     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:            Reversing MACD Indicator	Version:            1.00  14/11/2011Formula Parameters:                     Default:Price Source                            ClosePeriod Fast                             12Period Slow                             26Period Signal                           9Plot Chart                              PMACDBollinger Bands Period                  10Notes:    The related article is copyrighted material. If you are not a subscriber    of Stocks & Commodities, please visit www.traders.com.**********************************/// predefined constantsvar BBSTDEV = 1;var fpArray = new Array();function preMain(){          setPriceStudy(false);    setStudyTitle("Reversing MACD Indicator");        var x=0;    fpArray[x] = new FunctionParameter("priceSource", FunctionParameter.STRING);    with(fpArray[x++])    {	setName("Price Source");        addOption("Open");        addOption("Close");        addOption("Low");        addOption("High");        addOption("HL/2");        addOption("HLC/3");        addOption("OHLC/4");        setDefault("Close");    }     fpArray[x] = new FunctionParameter("pFast", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("Period Fast");	setLowerLimit(1);        setUpperLimit(24);        setDefault(12);    }        fpArray[x] = new FunctionParameter("pSlow", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("Period Slow");	setLowerLimit(2);        setUpperLimit(52);        setDefault(26);    }        fpArray[x] = new FunctionParameter("pSignal", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("Period Signal");	setLowerLimit(1);        setUpperLimit(18);        setDefault(9);    }        fpArray[x] = new FunctionParameter("pPlotIndicator", FunctionParameter.STRING);    with(fpArray[x++])    {	setName("Plot Indicator");        addOption("MACD");        addOption("MACD_HLC");        addOption("MACD_BB");        addOption("MACD_MTF");        setDefault("MACD");          }      fpArray[x] = new FunctionParameter("pBBPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("Bollinger Bands Period");	setLowerLimit(2);        setUpperLimit(20);        setDefault(10);    }}var bInit = false;var bVersion = null;var xSource = null;var xMACD_0 = null;var xMACDeq = null;function main(priceSource, pFast, pSlow, pSignal, pPlotIndicator, pBBPeriod){    if (bVersion == null) bVersion = verify();    if (bVersion == false) return;               if(!bInit)    {        switch (priceSource)        {                case 'Open':                    xSource = open();                   break;                case 'Close':                   xSource = close();                   break;                case 'High':                   xSource = high();                   break;                case 'Low':                   xSource = low();                   break;                case 'HL/2':                   xSource = hl2();                   break;                case 'HLC/3':                   xSource = hlc3();                   break;                case 'OHLC/4':                   xSource = ohlc4();                   break;                default : return;        }            }        var resultArr = null;        switch (pPlotIndicator)    {        case "MACD" :            resultArr = calc_MACD(xSource, pFast, pSlow, pSignal);            break;                case "MACD_HLC" :            resultArr = calc_MACD_HLC(pFast, pSlow);             break;                case "MACD_BB" :            resultArr = calc_MACD_BB(xSource, pFast, pSlow, pSignal, pBBPeriod);            break;                case "MACD_MTF" :             resultArr = calc_MACD_MTF(xSource, pFast, pSlow, pSignal);            break;                default :             bInit = true;            return;    }           return resultArr;}// calc_MACDvar xMACD = null;var xEMA = null;function calc_MACD(xSource, pFast, pSlow, pSignal){    if(!bInit)    {        xMACD = macd(pFast, pSlow, 1, xSource);        xEMA = ema(pSignal, xMACD);                              xMACDeq = efsInternal("PMACDeq", pFast, pSlow, xSource);        xMACD_0 = efsInternal("PMACDzero", pFast, pSlow, xSource);                setCursorLabelName("MACD", 0);        setCursorLabelName("Signal", 1);        setCursorLabelName("MACD Histogram", 2);        setCursorLabelName("PMACDeq", 3);        setCursorLabelName("PMACDzero", 4);                setDefaultBarThickness(2, 0);        setDefaultBarThickness(1, 1);        setDefaultBarThickness(1, 2);        setDefaultBarThickness(1, 3);        setDefaultBarThickness(1, 4);                      setShowCursorLabel(false, 2);        setPlotType(PLOTTYPE_HISTOGRAM, 2);                setShowSeries(false, 3);        setShowSeries(false, 4);                setDefaultBarFgColor(Color.RGB(0, 100, 255) , 0);        setDefaultBarFgColor(Color.RGB(255, 100, 0), 1);        setDefaultBarFgColor(Color.purple, 2);        setDefaultBarFgColor(Color.aqua, 3);        setDefaultBarFgColor(Color.yellow, 4);                bInit = true;    }    var nMACD = xMACD.getValue(0);    var nEMA = xEMA.getValue(0);        if(nEMA == null)        return;        var nMACDeq = xMACDeq.getValue(0);    var nMACD_0 = xMACD_0.getValue(0);          return new Array(nMACD, nEMA, nMACD - nEMA, nMACDeq, nMACD_0);}// calc_MACD_HLCvar xMACD_H = null;var xMACD_C = null;var xMACD_L = null;function calc_MACD_HLC(pFast, pSlow){    if(!bInit)    {        xMACD_H = macd(pFast, pSlow, 1, high());        xMACD_C = macd(pFast, pSlow, 1, close());        xMACD_L = macd(pFast, pSlow, 1, low());                setCursorLabelName("MACD(High)", 0);        setCursorLabelName("MACD(Close)", 1);        setCursorLabelName("MACD(Low)", 2);        setCursorLabelName("zero level", 3);                setShowCursorLabel(false, 3);                setDefaultBarThickness(1, 0);        setDefaultBarThickness(2, 1);        setDefaultBarThickness(1, 2);        setDefaultBarThickness(1, 3);                setDefaultBarFgColor(Color.lime, 0);        setDefaultBarFgColor(Color.RGB(0, 100, 255), 1);        setDefaultBarFgColor(Color.RGB(255, 100, 0), 2);         setDefaultBarFgColor(Color.grey, 3);                 bInit = true;    }    var nMACD_H = xMACD_H.getValue(0);    var nMACD_C = xMACD_C.getValue(0);    var nMACD_L = xMACD_L.getValue(0);        if(nMACD_H == null || nMACD_C == null || nMACD_L == null)        return;        return new Array(nMACD_H, nMACD_C, nMACD_L, 0);}// calc_MACD_BBvar xMACD_BB = null;var xEMA_BB = null;var xMACD_bTop = null;var xMACD_bBot = null;function calc_MACD_BB(xSource, pFast, pSlow, pSignal, pBBPeriod){    if(!bInit)    {        xMACD_BB = macd(pFast, pSlow, 1, xSource);        xEMA_BB = ema(pSignal, xMACD_BB);        xMACD_bTop = upperBB(pBBPeriod, BBSTDEV, xMACD_BB);        xMACD_bBot = lowerBB(pBBPeriod, BBSTDEV, xMACD_BB);                        setCursorLabelName("MACD", 0);        setCursorLabelName("MACD Histogram", 1);        setCursorLabelName("BBTop", 2);        setCursorLabelName("BBBot", 3);        setCursorLabelName("(BBTop + BBBot)/2", 4);                setDefaultBarThickness(2, 0);        setDefaultBarThickness(1, 1);        setDefaultBarThickness(1, 2);        setDefaultBarThickness(1, 3);        setDefaultBarThickness(1, 4);                setShowCursorLabel(false, 1);        setShowCursorLabel(false, 4);                setPlotType(PLOTTYPE_HISTOGRAM, 1);                setDefaultBarFgColor(Color.darkgreen, 2);        setDefaultBarFgColor(Color.maroon, 3);        setDefaultBarFgColor(Color.grey, 4);                bInit = true;    }    var nMACD_BB = xMACD_BB.getValue(0);    var nnMACD_BB = xMACD_BB.getValue(-1);            if(nMACD_BB < 0 && nMACD_BB > nnMACD_BB)        setDefaultBarFgColor(Color.RGB(200, 255, 0), 0);    else         if (nMACD_BB > 0 && nMACD_BB > nnMACD_BB)            setDefaultBarFgColor(Color.RGB(70, 255, 0), 0);        else            if (nMACD_BB > 0 && nMACD_BB < nnMACD_BB)                setDefaultBarFgColor(Color.RGB(255, 100, 0), 0);            else                 setDefaultBarFgColor(Color.red, 0);                var nEMA_BB = xEMA_BB.getValue(0);            var nHist = nMACD_BB - nEMA_BB;                        if(nHist > 0)        setDefaultBarFgColor(Color.purple, 1);    else        setDefaultBarFgColor(Color.RGB(0, 100, 255), 1);                            var nMACD_bTop = xMACD_bTop.getValue(0);    var nMACD_bBot = xMACD_bBot.getValue(0);        if (nEMA_BB == null || nMACD_bTop == null || nMACD_bBot == null)        return;        return new Array(nMACD_BB, nHist, nMACD_bTop, nMACD_bBot, (nMACD_bTop + nMACD_bBot) / 2);}// calc_MACD_MTFvar xMACD_MTF = null;var xMACD_MTF5 = null;var xMACD_MTF21 = null;function calc_MACD_MTF(xSource, pFast, pSlow, pSignal){    if(!bInit)    {        xMACD_MTF = macd(pFast, pSlow, xSource);        xMACD_MTF5 = macd(5 * pFast, 5 * pSlow, xSource);        xMACD_MTF21 = macd(21 * pFast, 21 * pSlow, xSource);                xMACDeq = efsInternal("PMACDeq", pFast, pSlow, xSource);        xMACD_0 = efsInternal("PMACDzero", pFast, pSlow, xSource);                setCursorLabelName("MACD", 0);        setCursorLabelName("5*MACD", 1);        setCursorLabelName("21*MACD", 2);        setCursorLabelName("PMACDeq", 3);        setCursorLabelName("PMACDzero", 4);        setCursorLabelName("zero level", 5);                setDefaultBarThickness(2, 0);        setDefaultBarThickness(1, 1);        setDefaultBarThickness(1, 2);        setDefaultBarThickness(1, 3);        setDefaultBarThickness(1, 4);        setDefaultBarThickness(1, 5);                setShowSeries(false, 3);        setShowSeries(false, 4);        setShowCursorLabel(false, 5);                setDefaultBarFgColor(Color.RGB(0, 100, 255), 0);        setDefaultBarFgColor(Color.lime, 1);        setDefaultBarFgColor(Color.RGB(255, 100, 0), 2);        setDefaultBarFgColor(Color.aqua, 3);        setDefaultBarFgColor(Color.yellow, 4);        setDefaultBarFgColor(Color.grey, 5);                 bInit = true;    }      var nMACD_MTF = xMACD_MTF.getValue(0);    var nMACD_MTF5 = xMACD_MTF5.getValue(0);    var nMACD_MTF21 = xMACD_MTF21.getValue(0);        if(nMACD_MTF == null)        return;        var nMACDeq = xMACDeq.getValue(0);    var nMACD_0 = xMACD_0.getValue(0);          return new Array(nMACD_MTF, nMACD_MTF5, nMACD_MTF21, nMACDeq, nMACD_0, 0);   }/*************************************************             SUPPORT FUNCTIONS                    **************************************************/   // PMACDeq - calculates what the next bar price needs to be for the MACD value to be the same.var alphaX_eq = null;var alphaY_eq = null;var xEMAx_eq = null;var xEMAy_eq = null;var PMACDeq_Init = false;function PMACDeq(periodX, periodY, xSeries){        if(!PMACDeq_Init)    {        alphaX_eq = 2 / (1 + periodX);        alphaY_eq = 2 / (1 + periodY);        xEMAx_eq = ema(periodX, xSeries);        xEMAy_eq = ema(periodY, xSeries);                      PMACDeq_Init = true;    }        var nEMAx = xEMAx_eq.getValue(-1);    var nEMAy = xEMAy_eq.getValue(-1);        if (nEMAx == null || nEMAy == null)        return;        var result = (alphaX_eq * nEMAx - alphaY_eq * nEMAy) / (alphaX_eq - alphaY_eq);        return result;}// PMACDLevel - calculates what the price needs to be for the MACD value to be particular constant value.var alphaX_lev = null;var alphaY_lev = null;var xEMAx_lev = null;var xEMAy_lev = null;var PMACDLevel_Init = false;function PMACDLevel(periodX, periodY, level, xSeries){    if(!PMACDLevel_Init)    {        alphaX_lev = 2 / (1 + periodX);        alphaY_lev = 2 / (1 + periodY);        xEMAx_lev = ema(periodX, xSeries);        xEMAy_lev = ema(periodY, xSeries);                PMACDLevel_Init = true;    }        var nEMAx = xEMAx_lev.getValue(-1);    var nEMAy = xEMAy_lev.getValue(-1);        if (nEMAx == null || nEMAy == null)        return;        var result = (level + (1 - alphaY_lev) * nEMAy - (1 - alphaX_lev) * nEMAx) / (alphaX_lev - alphaY_lev);        return result;}// PMACDzerofunction PMACDzero(periodX, periodY, xSeries){    return PMACDLevel(periodX, periodY, 0, xSeries);}// verify versionfunction 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;}