Announcement

Collapse
No announcement yet.

Uni-Channel

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

  • Uni-Channel

    File Name: Uni_channel.efs

    Description:
    This is the Uni-channel indicator from Ensign. The type designation of 1
    means that a constant value is added to the moving average value. Type 2
    means that percentage value is added to the moving average.


    Formula Parameters:
    Moving average source: close
    Moving average length: 10
    Upper band width: 0.8
    Lower band width: 1.2
    Mode of indicator: 1


    Notes:
    Bands define the upper and lower boundaries of a security's normal trading
    range. A sell signal is generated when the security reaches the upper band
    whereas a buy signal is generated at the lower band. The optimum percentage
    shift depends on the volatility of the security--the more volatile, the larger
    the percentage.

    The logic behind bands is that overzealous buyers and sellers push the price
    to the extremes (i.e., the upper and lower bands), at which point the prices
    often stabilize by moving to more realistic levels.

    There are two kinds of bands: envelopes and Bollinger bands.

    The difference between Bollinger bands and envelopes is envelopes are plotted at a
    fixed percentage above and below a moving average, whereas Bollinger bands are plotted
    at standard deviation levels above and below a moving average. Since standard deviation
    is a measure of volatility, the bands are self-adjusting: widening during volatile markets
    and contracting during calmer periods. Bollinger Bands were created by John Bollinger.


    Download File:
    Uni_channel.efs



    EFS Code:
    PHP Code:
    /*********************************

    Provided By:  

        eSignal (Copyright c eSignal), a division of Interactive Data 
        Corporation. 2008. 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:        

        This is the Uni-channel indicator from Ensign. The type designation of 1
        means that a constant value is added to the moving average value. Type 2
        means that percentage value is added to the moving average.

    Version:            1.0  09/30/2008

    Notes:

        Bands define the upper and lower boundaries of a security's normal trading 
        range. A sell signal is generated when the security reaches the upper band 
        whereas a buy signal is generated at the lower band. The optimum percentage 
        shift depends on the volatility of the security--the more volatile, the larger
        the percentage.

        The logic behind bands is that overzealous buyers and sellers push the price 
        to the extremes (i.e., the upper and lower bands), at which point the prices 
        often stabilize by moving to more realistic levels.

        There are two kinds of bands: envelopes and Bollinger bands.

        The difference between Bollinger bands and envelopes is envelopes are plotted at a 
        fixed percentage above and below a moving average, whereas Bollinger bands are plotted 
        at standard deviation levels above and below a moving average. Since standard deviation 
        is a measure of volatility, the bands are self-adjusting: widening during volatile markets 
        and contracting during calmer periods. Bollinger Bands were created by John Bollinger.


    Formula Parameters:                     Default:

        Moving average source                 close
        Moving average length                    10
        Upper band width                        0.8
        Lower band width                        1.2
        Mode of indicator                         1

    **********************************/


    var fpArray = new Array();
    var 
    bInit false;

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Uni - Channel");
        
    setCursorLabelName("CentLine"0);
        
    setCursorLabelName("Upper"1);
        
    setCursorLabelName("Lower"2);
        
    setDefaultBarFgColor(Color.aqua0);
        
    setDefaultBarFgColor(Color.blue1);
        
    setDefaultBarFgColor(Color.magenta2);
        
        
    askForInput();
        var 
    x=0;
        
        
    fpArray[x] = new FunctionParameter("Price"FunctionParameter.STRING);
        
    with(fpArray[x++]){
            
    setName("Moving average source");
            
    addOption("open"); 
            
    addOption("high");
            
    addOption("low");
            
    addOption("close");
            
    addOption("hl2");
            
    addOption("hlc3");
            
    addOption("ohlc4"); 
            
    setDefault("close"); 
        } 
       
        
    fpArray[x] = new FunctionParameter("MaLen"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Average length");
            
    setLowerLimit(1);        
            
    setDefault(10);
        }
        
        
    fpArray[x] = new FunctionParameter("Const1"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Upper band multiplier");
            
    setLowerLimit(0.01);        
            
    setDefault(0.8);
        }
        
        
    fpArray[x] = new FunctionParameter("Const2"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Lower band multiplier");
            
    setLowerLimit(0.01);        
            
    setDefault(1.2);
        }
        
        
    fpArray[x] = new FunctionParameter("Type"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Mode of indicator");    
            
    addOption(1); 
            
    addOption(2);
            
    setDefault(1);
        }
    }

    var 
    xPrice null;
    var 
    xUpper null;
    var 
    xLower null;
    var 
    xMA null;


    function 
    main(PriceMaLenConst1Const2Type) {
        var 
    nBarState getBarState();
        
        if(
    nBarState == BARSTATE_ALLBARS) {
            if (
    Price == nullPrice "close";
            if (
    MaLen == nullMaLen 10;
            if (
    Const1 == nullConst1 0.8;
            if (
    Const2 == nullConst2 1.2;
            if (
    Type == nullType 1;
        } 
        
        if (
    bInit == false) {
            
    xPrice = eval(Price)();
            
    xMA sma(MaLenxPrice);
            
            if (
    Type == 2) {
                
    xUpper upperEnv(MaLenfalseConst1xPrice);
                
    xLower lowerEnv(MaLenfalseConst2xPrice);
            }
        
            
    bInit true;
        }
        
        var 
    nUpper 0;
        var 
    nLower 0;
        
        var 
    nMA xMA.getValue(0);
        
        if (
    Type == 1) {
            
    nUpper nMA Const1;
            
    nLower nMA Const2;
        } else if (
    Type == 2) {
            
    nUpper xUpper.getValue(0);
            
    nLower xLower.getValue(0);
        } else return;
        
        if (
    getCurrentBarCount() < MaLen) return;
        
        return new Array(
    nMAnUppernLower);

Working...
X