Announcement

Collapse
No announcement yet.

CCI Syntax

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CCI Syntax

    Can anyone tell me why this Bollinger on CCI is using the close of CCI instead of (H+L)/C

    TIA


    Inputs:
    nCCILength - Length of CCI (Default: 14, "(H+L)/2")
    CCISource - Source for CCI (Default: "Close")
    nBandLength - Length of Bollinger Bands (Default: 20)
    nStdDev - Standard Deviations for BB (Default: 2.0)

    */

    var study = null;
    var study2 = null;

    function preMain() {
    setDefaultBarFgColor(Color.blue, 0); // upper
    setDefaultBarFgColor(Color.red, 1); // basis
    setDefaultBarFgColor(Color.blue, 2); // lower

    setStudyTitle("RSI w/ Bands");
    setCursorLabelName("Upper",0);
    setCursorLabelName("Basis",1);
    setCursorLabelName("Lower",2);
    setCursorLabelName("RSI",3);

    setDefaultBarFgColor(Color.blue,0);
    setDefaultBarFgColor(Color.red,1);
    setDefaultBarFgColor(Color.blue,2);
    setDefaultBarFgColor(Color.green,3);
    }

    function main(nCCILength,nCCISource,nBandLength,nStdDev) {

    if (nCCILength == null) nCCILength = 14, "(H+L)/2";
    if (nCCISource == null) nCCISource = verifySource(nCCISource);
    if (nBandLength == null) nBandLength = 20;
    if (nStdDev == null) nStdDev = 2.0;

    if (study == null) study = new CCIStudy(nCCILength, nCCISource);
    if (study2 == null) study2 = new BollingerStudy(nBandLength, study, CCIStudy.CCI, nStdDev)

    var vCCI = study.getValue(CCIStudy.CCI);
    var vUpper = study2.getValue(BollingerStudy.UPPER);
    var vBasis = study2.getValue(BollingerStudy.BASIS);
    var vLower = study2.getValue(BollingerStudy.LOWER);


    return new Array(vUpper, vBasis, vLower, vCCI);
    }

    /*** Utility Function ***/
    // Verifies source input and returns valid source


    function verifySource(nSource) {

    if (nSource == "close" || nSource =="C" ||
    nSource =="Close" || nSource =="c") {
    nSource = "Close";

    } else if (nSource == "open" || nSource =="O" ||
    nSource =="Open" || nSource =="o") {
    nSource = "Open";

    } else if (nSource == "high" || nSource =="H" ||
    nSource == "High" || nSource == "h") {
    nSource = "High";

    } else if (nSource == "low" || nSource =="L" ||
    nSource =="Low" || nSource =="l") {
    nSource = "Low";

    } else if (nSource == "hl/2" || nSource =="HL2" ||
    nSource =="HL/2" || nSource =="hl2") {
    nSource = "HL/2";

    } else if (nSource == "hlc/3" || nSource =="hlc3" ||
    nSource =="HLC/3" || nSource =="HLC3") {
    nSource = "HLC/3";

    } else if (nSource == "ohlc/4" || nSource =="ohlc4" ||
    nSource =="OHLC/4" || nSource =="OHLC4") {
    nSource = "OHLC/4";

    } else {
    nSource = "Close";
    }

    return nSource;
    }

  • #2
    I bet

    if (nCCILength == null) nCCILength = 14, "(H+L)/2";
    if (nCCISource == null) nCCISource = verifySource(nCCISource);

    is not valid syntax.

    Try something like

    if (nCCILength == null) {
    nCCILength = 14;
    nCCISource = "(H+L)/2";
    }

    if (nCCISource != null) verifySource(nCCISource);

    Comment

    Working...
    X