2011 Nov: Constructing The Put/Call Ratio Indicator by Sylvain Vervoort

ICE Data Services -


PCRI_Fast.efs, PCRI_Slow.efs, PCRI_Slow_IFT.efs  EFSLibrary - Discussion Board
  

File Name: PCRI_Fast.efs, PCRI_Slow.efs, PCRI_Slow_IFT.efs

Description:
Constructing The Put/Call Ratio Indicator by Sylvain Vervoort


Formula Parameters:

PCRI_Fast.efs
TEMA period: 5
PC ratio RSI period: 5
PCRI Indicator Period: 5
PC ratio rainbow average period: 2
Base Period: 200
Offset Period: 200

PCRI_Slow.efs
PC ratio rainbow average period: 5
PCRI period: 1

PCRI_Slow_IFT.efs
PC ratio rainbow average period: 4
PCRI period: 2
RSI period: 8

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

Download File:
PCRI_Fast.efs
PCRI_Slow.efs
PCRI_Slow_IFT.efs

PCRI_Fast.efs, PCRI_Slow.efs


PCRI_Slow.efs, PCRI_Slow_IFT.efs



EFS Code:

PCRI_Fast.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:            Fast Put/Call Ratio Indicator	Version:            1.00  15/09/2011Formula Parameters:                     Default:TEMA period                             5PC ratio RSI period                     5PCRI Indicator Period                   5PC ratio rainbow average period         2Base Period                             200Offset Period                           200Notes:    The related article is copyrighted material. If you are not a subscriber    of Stocks & Commodities, please visit www.traders.com.**********************************/// predefined constantsvar PCRATIO_LOW = 0.45;var PCRATIO_HIGH = 0.9;var fpArray = new Array();function preMain(){          setPriceStudy(false);        setCursorLabelName("PCRI_Fast", 0);    setCursorLabelName("high", 1);    setCursorLabelName("low", 2);    setCursorLabelName("base", 3);        setDefaultBarFgColor(Color.green, 1);    setDefaultBarFgColor(Color.green, 2);    setDefaultBarFgColor(Color.grey, 3);        setDefaultBarThickness(0, 1);    setDefaultBarThickness(0, 2);    setDefaultBarThickness(1, 3);            var x=0;    fpArray[x] = new FunctionParameter("temaPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("TEMA Period");	setLowerLimit(1);        setUpperLimit(100);        setDefault(5);    }     fpArray[x] = new FunctionParameter("rsiPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("PC Ratio RSI Period");	setLowerLimit(2);        setUpperLimit(100);        setDefault(5);    }        fpArray[x] = new FunctionParameter("pcriPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("PCRI Indicator Period");	setLowerLimit(1);        setUpperLimit(100);        setDefault(5);    }        fpArray[x] = new FunctionParameter("rainbPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("PC ratio rainbow average period");	setLowerLimit(1);        setUpperLimit(10);        setDefault(2);    }        fpArray[x] = new FunctionParameter("basePeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("Base Period");	setLowerLimit(1);        setUpperLimit(500);        setDefault(200);    }        fpArray[x] = new FunctionParameter("offsetPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("Offset Period");	setLowerLimit(1);        setUpperLimit(500);        setDefault(200);    }    }var bInit = false;var bVersion = null;var xPCratio = null;var xPC = null;var xPCtema = null;var xRainb = null;var xPCRI = null;var xBase = null;var xOffset = null;function main(temaPeriod, rsiPeriod, pcriPeriod, rainbPeriod, basePeriod, offsetPeriod){    if (bVersion == null) bVersion = verify();    if (bVersion == false) return;              if (!bInit)    {        xPCratio = close(sym("$PCCE-ST"));                xPC = efsInternal("LimitPC", PCRATIO_LOW, PCRATIO_HIGH, xPCratio);                xPCtema = efsInternal("TEMA", temaPeriod, xPC);                xRainb = efsInternal("RainbowAverage", rainbPeriod, xPCtema);                xPCRI = wma(pcriPeriod, rsi(rsiPeriod, xRainb));                xBase = sma(basePeriod, xPCRI);        xOffset = efsInternal("MSTD", offsetPeriod, xPCRI);                bInit = true;    }              var vBase = xBase.getValue(0);    var vOffset = xOffset.getValue(0);        var lowLine = null;    var highLine = null;        if (vBase != null && vOffset != null)     {        lowLine = vBase - 1.3 * vOffset;        highLine = vBase + 1.3 * vOffset;    }        var baseLine = 50;        var vPCRI = xPCRI.getValue(0);        if (vPCRI == null)         return null;           return new Array(vPCRI, highLine, lowLine, baseLine);}/*************************************************             SUPPORT FUNCTIONS                    **************************************************/   var bInitRainbow = false;var xWMA1 = null;var xWMA2 = null;var xWMA3 = null;var xWMA4 = null;var xWMA5 = null;var xWMA6 = null;var xWMA7 = null;var xWMA8 = null;var xWMA9 = null;var xWMA10 = null;// rainbow averaging techniquefunction RainbowAverage(period, series){    if (!bInitRainbow)    {            xWMA1 = wma(period, series);            xWMA2 = wma(period, xWMA1);            xWMA3 = wma(period, xWMA2);            xWMA4 = wma(period, xWMA3);            xWMA5 = wma(period, xWMA4);            xWMA6 = wma(period, xWMA5);            xWMA7 = wma(period, xWMA6);            xWMA8 = wma(period, xWMA7);            xWMA9 = wma(period, xWMA8);            xWMA10 = wma(period, xWMA9);                    bInitRainbow = true;    }        var vWMA1 = xWMA1.getValue(0);    var vWMA2 = xWMA2.getValue(0);    var vWMA3 = xWMA3.getValue(0);    var vWMA4 = xWMA4.getValue(0);    var vWMA5 = xWMA5.getValue(0);    var vWMA6 = xWMA6.getValue(0);    var vWMA7 = xWMA7.getValue(0);    var vWMA8 = xWMA8.getValue(0);    var vWMA9 = xWMA9.getValue(0);    var vWMA10 = xWMA10.getValue(0);        if (vWMA10 == null)         return null;        var nRes = (vWMA1 + vWMA2 + vWMA3 + vWMA4 + vWMA5 + vWMA6 + vWMA7 + vWMA8 + vWMA9 + vWMA10)/10;         return nRes;}// Limited Put/Call ratiofunction LimitPC(lowLevel, highLevel, PCratio){       var PCLim = PCratio.getValue(0);        if (PCLim == null) return null;        if(PCLim > highLevel)        PCLim = highLevel;    else if (PCLim < lowLevel)        PCLim = lowLevel;       return PCLim;}var bInitTEMA = false;var xEma1 = null;var xEma2 = null;var xEma3 = null;// Triple Exponential Moving Averagefunction TEMA(period, series){       if(!bInitTEMA)    {        xEma1 = ema(period, series);        xEma2 = ema(period, xEma1);        xEma3 = ema(period, xEma2);                bInitTEMA = true;        }           var vEma1 = xEma1.getValue(0);    var vEma2 = xEma2.getValue(0);    var vEma3 = xEma3.getValue(0);        if (vEma3 == null)         return null;        return 3 * vEma1 - 3 * vEma2 + vEma3;}// Moving Standard Deviation (MSTD)var aPr = new Array();  var sPr = 0;            var sPr2 = 0;           function MSTD(period, series){        var vPr0 = series.getValue(0);                if ( getBarState() == BARSTATE_ALLBARS )        {            aPr.length = 0;            sPr = 0;             sPr2 = 0;        }        if ( getBarState() == BARSTATE_NEWBAR )        {            if (aPr.length >= period )            {                sPr-=aPr[0];                sPr2-=aPr[0]*aPr[0];                aPr.shift();            }            sPr+=vPr0;            sPr2+=vPr0*vPr0;            aPr.push(vPr0);        }        if ( getBarState() == BARSTATE_CURRENTBAR )         {            sPr-=aPr[aPr.length-1];            sPr2-=aPr[aPr.length-1]*aPr[aPr.length-1];            sPr+=vPr0;            sPr2+=vPr0*vPr0;            aPr[aPr.length-1] = vPr0;            }        var stdDev = null;        if (aPr.length == period )        {            stdDev = Math.sqrt( ( period*sPr2 - sPr*sPr )/( period*( period-1 )) );        }                           return stdDev;}// 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;}


PCRI_Slow.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:            Slow Put/Call Ratio Indicator	Version:            1.00  15/09/2011Formula Parameters:                     Default:PC ratio rainbow average period         5PCRI period                             1Notes:    The related article is copyrighted material. If you are not a subscriber    of Stocks & Commodities, please visit www.traders.com.**********************************/// predefined constantsvar PCRATIO_LOW = 0.45;var PCRATIO_HIGH = 0.9;var fpArray = new Array();function preMain(){          setPriceStudy(false);    setCursorLabelName("PCRI_Slow", 0);        var x=0;    fpArray[x] = new FunctionParameter("rainbPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("PC ratio rainbow average period");	setLowerLimit(1);        setUpperLimit(10);        setDefault(5);    }     fpArray[x] = new FunctionParameter("pcriPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("PCRI period");	setLowerLimit(1);        setUpperLimit(100);        setDefault(1);    }    }var bInit = false;var bVersion = null;var xPCratio = null;var xPC = null;var xRainb = null;var xPCRI = null;function main(rainbPeriod, pcriPeriod){    if (bVersion == null) bVersion = verify();    if (bVersion == false) return;              if (!bInit)    {        xPCratio = close(sym("$PCCE-ST"));        xPC = efsInternal("LimitPC",  PCRATIO_LOW, PCRATIO_HIGH, xPCratio);                xRainb = efsInternal("RainbowAverage", rainbPeriod, xPC);        xPCRI = wma(pcriPeriod, xRainb);                bInit = true;    }                   var vPCRI = xPCRI.getValue(0);         if (vPCRI == null )         return null;        return vPCRI;}/*************************************************             SUPPORT FUNCTIONS                    **************************************************/   var bInitRainbow = false;var xWMA1 = null;var xWMA2 = null;var xWMA3 = null;var xWMA4 = null;var xWMA5 = null;var xWMA6 = null;var xWMA7 = null;var xWMA8 = null;var xWMA9 = null;var xWMA10 = null;// rainbow averaging techniquefunction RainbowAverage(period, series){    if (!bInitRainbow)    {            xWMA1 = wma(period, series);            xWMA2 = wma(period, xWMA1);            xWMA3 = wma(period, xWMA2);            xWMA4 = wma(period, xWMA3);            xWMA5 = wma(period, xWMA4);            xWMA6 = wma(period, xWMA5);            xWMA7 = wma(period, xWMA6);            xWMA8 = wma(period, xWMA7);            xWMA9 = wma(period, xWMA8);            xWMA10 = wma(period, xWMA9);                    bInitRainbow = true;    }        var nRes = 0;    var vWMA1 = xWMA1.getValue(0);    var vWMA2 = xWMA2.getValue(0);    var vWMA3 = xWMA3.getValue(0);    var vWMA4 = xWMA4.getValue(0);    var vWMA5 = xWMA5.getValue(0);    var vWMA6 = xWMA6.getValue(0);    var vWMA7 = xWMA7.getValue(0);    var vWMA8 = xWMA8.getValue(0);    var vWMA9 = xWMA9.getValue(0);    var vWMA10 = xWMA10.getValue(0);        if (vWMA10 == null)         return null;        nRes = (vWMA1 + vWMA2 + vWMA3 + vWMA4 + vWMA5 + vWMA6 + vWMA7 + vWMA8 + vWMA9 + vWMA10)/10;         return nRes; }// Limited Put/Call ratiofunction LimitPC(lowLevel, highLevel, PCratio){       var PCLim = PCratio.getValue(0);        if (PCLim == null)         return null;        if(PCLim > highLevel)        PCLim = highLevel;    else if (PCLim < lowLevel)        PCLim = lowLevel;       return PCLim;}// 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;}


PCRI_Slow_IFT.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:            PCRI Slow Inverse Fisher Transform Indicator	Version:            1.00  15/09/2011Formula Parameters:                     Default:PC ratio rainbow average period         4PCRI period                             2RSI period                              8Notes:    The related article is copyrighted material. If you are not a subscriber    of Stocks & Commodities, please visit www.traders.com.**********************************/// predefined constantsvar PCRATIO_LOW = 0.45;var PCRATIO_HIGH = 0.9;var fpArray = new Array();function preMain(){          setPriceStudy(false);    setCursorLabelName("PCRI_Slow_IFT", 0);        var x=0;    fpArray[x] = new FunctionParameter("rainbPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("PC ratio rainbow average period");	setLowerLimit(1);        setUpperLimit(10);        setDefault(4);    }     fpArray[x] = new FunctionParameter("pcriPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("PCRI period");	setLowerLimit(1);        setUpperLimit(100);        setDefault(2);    }               fpArray[x] = new FunctionParameter("rsiPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {	setName("RSI period");	setLowerLimit(1);        setUpperLimit(100);        setDefault(8);    }    }var bInit = false;var bVersion = null;var xPCratio = null;var xPC = null;var xRainb = null;var xPcri = null;var xPcriRsi = null;function main(rainbPeriod, pcriPeriod, rsiPeriod){    if (bVersion == null) bVersion = verify();    if (bVersion == false) return;              if (!bInit)    {        xPCratio = close(sym("$PCCE-ST"));                xPC = efsInternal("LimitPC", PCRATIO_LOW, PCRATIO_HIGH, xPCratio);                        xRainb = efsInternal("RainbowAverage", rainbPeriod, xPC);                xPcri = wma(pcriPeriod, xRainb);                xPcriRsi = rsi(rsiPeriod, xPcri);                      bInit = true;    }                      var vPcriRsi = xPcriRsi.getValue(0);        if(vPcriRsi == null)        return null;        var x = 0.1 * (vPcriRsi - 50);           var invfish = ((Math.exp(2*x)-1)/(Math.exp(2*x)+1)+1)*50;           return invfish;}/*************************************************             SUPPORT FUNCTIONS                    **************************************************/   var bInitRainbow = false;var xWMA1 = null;var xWMA2 = null;var xWMA3 = null;var xWMA4 = null;var xWMA5 = null;var xWMA6 = null;var xWMA7 = null;var xWMA8 = null;var xWMA9 = null;var xWMA10 = null;// rainbow averaging techniquefunction RainbowAverage(period, series){    if (!bInitRainbow)    {            xWMA1 = wma(period, series);            xWMA2 = wma(period, xWMA1);            xWMA3 = wma(period, xWMA2);            xWMA4 = wma(period, xWMA3);            xWMA5 = wma(period, xWMA4);            xWMA6 = wma(period, xWMA5);            xWMA7 = wma(period, xWMA6);            xWMA8 = wma(period, xWMA7);            xWMA9 = wma(period, xWMA8);            xWMA10 = wma(period, xWMA9);                    bInitRainbow = true;    }        var vWMA1 = xWMA1.getValue(0);    var vWMA2 = xWMA2.getValue(0);    var vWMA3 = xWMA3.getValue(0);    var vWMA4 = xWMA4.getValue(0);    var vWMA5 = xWMA5.getValue(0);    var vWMA6 = xWMA6.getValue(0);    var vWMA7 = xWMA7.getValue(0);    var vWMA8 = xWMA8.getValue(0);    var vWMA9 = xWMA9.getValue(0);    var vWMA10 = xWMA10.getValue(0);        if (vWMA10 == null)         return null;        var nRes = (vWMA1 + vWMA2 + vWMA3 + vWMA4 + vWMA5 + vWMA6 + vWMA7 + vWMA8 + vWMA9 + vWMA10)/10;        return nRes;}// Limited Put/Call ratiofunction LimitPC(lowLevel, highLevel, PCratio){       var PCLim = PCratio.getValue(0);        if (PCLim == null)        return null;        if(PCLim > highLevel)        PCLim = highLevel;    else if (PCLim < lowLevel)        PCLim = lowLevel;       return PCLim;}// 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;}