2006 Jul: The Wilson Relative Price Channel (Wilson_RPC.efs)

ICE Data Services -

Wilson_RPC.efs  
EFSLibrary - Discussion Board  

File Name: Wilson_RPC.efs

Description:
This study is based on the July 2006 article, The Wilson Relative Price Channel, by Leon Wilson

Formula Parameters:

  • Channel Periods: 34
  • Smoothing Periods: 1
  • Over Bought: 70
  • Over Sold: 30
  • Upper Neutral Zone: 55
  • Lower Neutral Zone: 45

Notes:
This formula requires eSignal version 7.9.1 or later. The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.

Download File:
Wilson_RPC.efs


EFS Code:

/***************************************
Provided By : eSignal (c) Copyright 2006
Description:  The Wilson Relative Price Channel
              by Leon Wilson

Version 1.0  05/05/2006

Notes:
* July 2006 Issue of Stocks and Commodities Magazine
* Study requires version 7.9.1 or higher.


Formula Parameters:                 Defaults:
Channel Periods                     34
Smoothing Periods                   1
Over Bought                         70
Over Sold                           30
Upper Neutral Zone                  55
Lower Neutral Zone                  45
***************************************/


function preMain() {
    setPriceStudy(true);
    setStudyTitle("The Wilson Relative Price Channel ");
    setCursorLabelName("Over Bought", 0);
    setCursorLabelName("Neutral Upper", 1);
    setCursorLabelName("Neutral Lower", 2);
    setCursorLabelName("Over Sold", 3);
    setShowTitleParameters(false);
    setDefaultBarFgColor(Color.black, 0);
    setDefaultBarFgColor(Color.black, 1);
    setDefaultBarFgColor(Color.black, 2);
    setDefaultBarFgColor(Color.black, 3);
    setPlotType(PLOTTYPE_SQUAREWAVE, 0);
    setPlotType(PLOTTYPE_SQUAREWAVE, 1);
    setPlotType(PLOTTYPE_SQUAREWAVE, 2);
    setPlotType(PLOTTYPE_SQUAREWAVE, 3);
    

    var fp1 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
        fp1.setName("Channel Periods");
        fp1.setLowerLimit(1);
        fp1.setUpperLimit(250);
        fp1.setDefault(34);
    var fp2 = new FunctionParameter("nSmoothing", FunctionParameter.NUMBER);
        fp2.setName("Smoothing Periods");
        fp2.setLowerLimit(1);
        fp2.setUpperLimit(55);
        fp2.setDefault(1);
    var fp3 = new FunctionParameter("nOB", FunctionParameter.NUMBER);
        fp3.setName("Over Bought");
        fp3.setLowerLimit(50);
        fp3.setUpperLimit(99);
        fp3.setDefault(70);
    var fp4 = new FunctionParameter("nOS", FunctionParameter.NUMBER);
        fp4.setName("Over Sold");
        fp4.setLowerLimit(1);
        fp4.setUpperLimit(50);
        fp4.setDefault(30);
    var fp5 = new FunctionParameter("nUpperNZ", FunctionParameter.NUMBER);
        fp5.setName("Upper Neutral Zone");
        fp5.setLowerLimit(50);
        fp5.setUpperLimit(99);
        fp5.setDefault(55);
    var fp6 = new FunctionParameter("nLowerNZ", FunctionParameter.NUMBER);
        fp6.setName("Lower Neutral Zone");
        fp6.setLowerLimit(1);
        fp6.setUpperLimit(50);
        fp6.setDefault(45);
}

var bVersion = null;
var bInit = false;

var xRPC = null;

function main(nPeriods, nSmoothing, nOB, nOS, nUpperNZ, nLowerNZ) {    
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;    

    if (bInit == false) {
        xRPC = efsInternal("calcRPC", nPeriods, nSmoothing, nOB, nOS, nUpperNZ, nLowerNZ);
        bInit = true;
    }
    
    var nRPC_OB = getSeries(xRPC, 0);  // Over Bought
    var nRPC_UN = getSeries(xRPC, 1);  // Upper Neutral
    var nRPC_LN = getSeries(xRPC, 2);  // Lower Neutral
    var nRPC_OS = getSeries(xRPC, 3);  // Over Sold

    setBarBgColor(Color.lightgrey, 0, nRPC_UN, nRPC_OB);
    setBarBgColor(Color.grey, 2, nRPC_LN, nRPC_OS);

    return new Array(nRPC_OB, nRPC_UN, nRPC_LN, nRPC_OS);
}

function calcRPC(nPeriods, nSmoothing, nOB, nOS, nUpperNZ, nLowerNZ) {
    var nC = close(0);
    var OB = ema(nSmoothing, efsInternal("calcCord", nPeriods, nOB),      0);
    var UN = ema(nSmoothing, efsInternal("calcCord", nPeriods, nUpperNZ), 0);
    var LN = ema(nSmoothing, efsInternal("calcCord", nPeriods, nLowerNZ), 0);
    var OS = ema(nSmoothing, efsInternal("calcCord", nPeriods, nOS),      0);
    
    OB = nC - (nC * (OB/100));
    UN = nC - (nC * (UN/100));
    LN = nC - (nC * (LN/100));
    OS = nC - (nC * (OS/100));
    
    return new Array(OB, UN, LN, OS);
}


function calcCord(nPeriods, nCord) {
    return (rsi(nPeriods, 0) - nCord);
}


function verify() {
    var b = false;
    if (getBuildNumber() < 730) {
        drawTextAbsolute(5, 35, "This study requires version 7.9.1 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;
}