Announcement

Collapse
No announcement yet.

keltner channel bands

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

  • keltner channel bands

    I would like to change the channel band to an (8,1.3%,1.3%). That is an 8 exponential moving average with a 1.3% above and below multiplier constant. Can any one tell me what needs to be changed on this page?

    function preMain() {
    setPriceStudy(true);

    /* Set the title that will appear in the study pane */
    setStudyTitle("Keltner EMA Bands");

    /* Set the label that will appear in the cursor window */
    setCursorLabelName("K-Upper", 0);
    setCursorLabelName("K-Basis", 1);
    setCursorLabelName("K-Lower", 2);

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

    var fp1 = new FunctionParameter("nInputLength", FunctionParameter.NUMBER);
    fp1.setName("Length");
    fp1.setLowerLimit(1);
    fp1.setDefault(10);
    }


    var xHminL = null;
    var xKeltnerEMA = null;

    function main(nInputLength) {
    if (xHminL == null) xHminL = efsInternal("HminL", nInputLength);
    if (xKeltnerEMA == null) xKeltnerEMA = ema(nInputLength, hlc3());

    var nKeltnerBasis = xKeltnerEMA.getValue(0);
    var nHminL = xHminL.getValue(0);
    if (nKeltnerBasis == null || nHminL == null) return;

    return new Array(nKeltnerBasis + nHminL, nKeltnerBasis, nKeltnerBasis - nHminL);
    }

    function HminL(n) {
    var dHminL = 0;

    for (var i = 0; i < n; i++) {
    dHminL += high(-i) - low(-i);
    }

    return (dHminL /= n);
    }

  • #2
    chevymike
    From your description it is not clear if you want to calculate 1.3% of the exponential average or of the average range. In the first case replace the return statement with
    PHP Code:
    return new Array(nKeltnerBasis + (nKeltnerBasis*0.013), nKeltnerBasisnKeltnerBasis - (nKeltnerBasis*0.013)); 
    In the other case replace it with the following
    PHP Code:
    return new Array(nKeltnerBasis + (nHminL*0.013), nKeltnerBasisnKeltnerBasis - (nHminL*0.013)); 
    Also you may want to see this forum which contains several variations of the Keltner Channel already programmed
    Alex

    Comment

    Working...
    X