Announcement

Collapse
No announcement yet.

MA Percent Channel

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MA Percent Channel

    File Name: MAPercentChannel.efs

    Description:
    MA Percent Channel

    Formula Parameters:
    MA Method : SMA
    MA Price Source : CLOSE
    Length : 55
    Shift : 0
    Deviation : 1


    Notes:


    Download File:
    MAPercentChannel.efs



    EFS Code:
    PHP Code:
    /*********************************
    Provided By:  
        eSignal (Copyright c eSignal), a division of Interactive Data 
        Corporation. 2009. All rights reserved. This sample eSignal 
        Formula Script (EFS) is for educational purposes only and may be 
        modified and saved under a new file name.  eSignal is not responsible
        for the functionality once modified.  eSignal reserves the right 
        to modify and overwrite this EFS file with each new release.

    Description:        
        MA Percent Channel 
    Version:            1.0  06/25/2009
     
    Formula Parameters:                     Default:
        MA Method                           SMA
        MA Price Source                     CLOSE
        Length                              55
        Shift                               0
        Deviation                           1
        
    Notes:
        
    **********************************/
    var fpArray = new Array();
    var 
    bInit false;

    function 
    preMain(){
        
    setPriceStudy(true);
        
    setShowCursorLabel(true);
        
    setShowTitleParameters(false);
        
    setStudyTitle("MA Percent Channel");
        
    setCursorLabelName("U1"0);
        
    setDefaultBarFgColor(Color.blue0);
        
    setPlotType(PLOTTYPE_LINE0);
        
    setDefaultBarThickness(10);
        
    setCursorLabelName("U2"1);
        
    setDefaultBarFgColor(Color.blue1);
        
    setPlotType(PLOTTYPE_LINE1);
        
    setDefaultBarThickness(11);
        
    setCursorLabelName("U3"2);
        
    setDefaultBarFgColor(Color.blue2);
        
    setPlotType(PLOTTYPE_LINE2);
        
    setDefaultBarThickness(22);
        
    setCursorLabelName("D1"3);
        
    setDefaultBarFgColor(Color.red3);
        
    setPlotType(PLOTTYPE_LINE3);
        
    setDefaultBarThickness(13);
        
    setCursorLabelName("D2"4);
        
    setDefaultBarFgColor(Color.red4);
        
    setPlotType(PLOTTYPE_LINE4);
        
    setDefaultBarThickness(14);
        
    setCursorLabelName("D3"5);
        
    setDefaultBarFgColor(Color.red5);
        
    setPlotType(PLOTTYPE_LINE5);
        
    setDefaultBarThickness(25);
        
    setCursorLabelName("LB"6);
        
    setDefaultBarFgColor(Color.green6);
        
    setPlotType(PLOTTYPE_LINE6);
        
    setDefaultBarThickness(26);
        var 
    0;
        
    fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
        
    with(fpArray[x++]) {
            
    setLowerLimit(1);
            
    setDefault(55);
        }    
        
    fpArray[x] = new FunctionParameter("Shift"FunctionParameter.NUMBER);
        
    with(fpArray[x++]) {
            
    setLowerLimit(0);
            
    setDefault(0);
        }        
        
    fpArray[x] = new FunctionParameter("Deviation"FunctionParameter.NUMBER);
        
    with(fpArray[x++]) {
            
    setLowerLimit(1);
            
    setDefault(1);
        }        
        
    fpArray[x] = new FunctionParameter("sMAType"FunctionParameter.STRING);
        
    with(fpArray[x++]) {
            
    setName("MA Method");
            
    addOption("sma");
            
    addOption("ema");
            
    addOption("wma");
            
    addOption("vwma");
            
    setDefault("sma");
        }
        
    fpArray[x] = new FunctionParameter("sMAPriceSource"FunctionParameter.STRING);
        
    with(fpArray[x++]) {
            
    setName("MA Price Source");
            
    addOption("open");
            
    addOption("high");
            
    addOption("low");
            
    addOption("close");
            
    addOption("hl2");
            
    addOption("hlc3"); 
            
    addOption("ohlc4");
            
    setDefault("close");
        }
    }

    var 
    xMA null;

    function 
    main(sMATypesMAPriceSourceLengthShiftDeviation) {
    var 
    nBarState getBarState();
    var 
    nMA1 0;
    var 
    nMA2 0;
    var 
    nMA3 0;
    var 
    nMA4 0;
    var 
    nMA5 0;
    var 
    nMA6 0;
    var 
    nMA7 0;
        if (
    nBarState == BARSTATE_ALLBARS) {
            if(
    Length == nullLength 55;
            if(
    Shift == nullShift 0;
            if(
    Deviation == nullDeviation 1;
            if(
    sMAType == nullsMAType "sma";
            if(
    sMAPriceSource == nullsMAPriceSource "close";
        }
        if (
    bInit == false) {
            
    xMA = eval(sMAType)(Length, eval(sMAPriceSource)());
            
    bInit true;
        }
        
    nMA7 xMA.getValue(-Shift);
        if (
    nMA7 == null) return;
        
    nMA1 = (Deviation 0.382 100) * nMA7;
        
    nMA4 = (Deviation 0.382 100) * nMA7;
        
    nMA2 = (Deviation 0.618 100) * nMA7;
        
    nMA5 = (Deviation 0.618 100) * nMA7;
        
    nMA3 = (Deviation 100) * nMA7;
        
    nMA6 = (Deviation 100) * nMA7;
        return new Array(
    nMA1nMA2nMA3nMA4nMA5nMA6nMA7);

Working...
X