Announcement

Collapse
No announcement yet.

Moving Average Ribbon

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

  • Moving Average Ribbon

    File Name: MovingAverageRibbon.efs

    Description:
    Moving Average Ribbon

    Formula Parameters:
    Base Length: 10
    Arithmetic Or Geometric 1 Or 2: 1
    Increment Or Multiplier: 10
    Line Thickness: 2
    Display Title Value: False


    Notes:
    Plots a "Moving Average Ribbon" using the gradient color system ╓ it
    is created using a series of exponential moving averages of various
    lengths. The lengths of the averages are calculated based on the length
    of the first moving average line which is set by the input BaseLength.
    Each subsequent length is calculated based on the ArithOrGeom_1or2 input.



    Download File:
    MovingAverageRibbon.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:        
        Moving Average Ribbon


    Version:            1.0.0  22/09/2008

    Formula Parameters:                     Default:
        * Base Length                          10
        * Arithmetic Or Geometric 1 Or 2        1
        * Increment Or Multiplier              10
        * Line Thickness                        2   
        * Display Title Value                False

     Notes:
        Plots a "Moving Average Ribbon" using the gradient color system ╓ it
        is created using a series of exponential moving averages of  various
        lengths.  The lengths of the averages are calculated based on the length
        of the first moving average line which is set by the input BaseLength.
        Each subsequent length is calculated based on the ArithOrGeom_1or2 input.

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

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

    function 
    preMain() {

        
    setPriceStudy(true);
        
    setShowCursorLabel(false);
        
    setShowTitleParametersfalse );
        
        
    setStudyTitle("Moving Average Ribbon");
        
    setCursorLabelName("XMA1"0);
        
    setCursorLabelName("XMA2"1);
        
    setCursorLabelName("XMA3"2);
        
    setCursorLabelName("XMA4"3);
        
    setCursorLabelName("XMA5"4);
        
    setCursorLabelName("XMA6"5);
        
    setCursorLabelName("XMA7"6);    
        
    setCursorLabelName("XMA8"7);

        
    setDefaultBarFgColor(Color.RGB(255,255,0), 7);
        
    setDefaultBarFgColor(Color.RGB(255,200,0), 6);
        
    setDefaultBarFgColor(Color.RGB(255,150,0), 5);
        
    setDefaultBarFgColor(Color.RGB(255,150,0), 4);
        
    setDefaultBarFgColor(Color.RGB(255,100,0), 3);
        
    setDefaultBarFgColor(Color.RGB(255,50,0), 2);
        
    setDefaultBarFgColor(Color.RGB(255,0,0), 1);
        
    setDefaultBarFgColor(Color.RGB(255,0,0), 0);
        
        
    setPlotType(PLOTTYPE_LINE0); 
        
    setPlotType(PLOTTYPE_LINE1); 
        
    setPlotType(PLOTTYPE_LINE2); 
        
    setPlotType(PLOTTYPE_LINE3); 
        
    setPlotType(PLOTTYPE_LINE4); 
        
    setPlotType(PLOTTYPE_LINE5); 
        
    setPlotType(PLOTTYPE_LINE6); 
        
    setPlotType(PLOTTYPE_LINE7);     
        
        
    setDefaultBarThickness(20);
        
    setDefaultBarThickness(21);
        
    setDefaultBarThickness(22);
        
    setDefaultBarThickness(23);
        
    setDefaultBarThickness(24);
        
    setDefaultBarThickness(25);
        
    setDefaultBarThickness(26);
        
    setDefaultBarThickness(27);    

       
        
    askForInput();
        var 
    x=0;
        
    fpArray[x] = new FunctionParameter("ViewValue"FunctionParameter.BOOLEAN);
        
    with(fpArray[x++]){
            
    setName("Display Cursor Labels");
            
    setDefault(false);
        }    
        
        
    fpArray[x] = new FunctionParameter("BaseLength"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Base Length");
            
    setLowerLimit(1);        
            
    setDefault(10);
        }

        
    fpArray[x] = new FunctionParameter("ArithOrGeom_1or2"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Arithmetic Or Geometric (1 Or 2)");
            
    setLowerLimit(1);        
            
    setDefault(1);
        }

        
    fpArray[x] = new FunctionParameter("IncrementOrMultiplier"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Increment Or Multiplier");
            
    setLowerLimit(1);        
            
    setDefault(10);
        }

        
    fpArray[x] = new FunctionParameter("Thickness"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Line Thickness");
            
    setLowerLimit(1);        
            
    setDefault(2);
        }
    }

    var    
    aLength = new Array(8);
    var    
    aSmoothingFactor = new Array(8);
    var    
    aXMA = new Array(8);
    var    
    aXMA_Ref = new Array(8);
    var    
    aColor = new Array(8);



    function 
    main(BaseLengthArithOrGeom_1or2IncrementOrMultiplierThickness,  ViewValue) {
    var 
    nCounter 0;
    var 
    nState getBarState();

        if ( 
    bInit == false ) { 
            
    setDefaultBarThickness(Thickness0);
            
    setDefaultBarThickness(Thickness1);
            
    setDefaultBarThickness(Thickness2);
            
    setDefaultBarThickness(Thickness3);
            
    setDefaultBarThickness(Thickness4);
            
    setDefaultBarThickness(Thickness5);
            
    setDefaultBarThickness(Thickness6);        
            
    setDefaultBarThickness(Thickness7);        
            
    setShowCursorLabel(ViewValue);        
            
    ClearArrays();
            
    bInit true
        } 

        if (
    nState == BARSTATE_NEWBAR) {
            for (var 
    1<= 8i++) {
                
    aXMA_Ref[i] = aXMA[i];
            }
        }

        if (
    getCurrentBarCount() == ) {
            
    aLength[1] = BaseLength ;
            
    aSmoothingFactor[1] = / ( aLength[1] + );
            
    aXMA[1] = close(0);
            for (
    nCounter 1nCounter <= 7nCounter++) {
                if (
    ArithOrGeom_1or2 == 1
                    
    aLength[nCounter 1] = aLength[nCounter] + IncrementOrMultiplier;
                else
                    
    aLength[nCounter 1] = aLength[nCounter] * IncrementOrMultiplier;

                
    aSmoothingFactor[nCounter 1] = / (aLength[nCounter 1] + 1);
                
    aXMA[nCounter 1] = close(0);
            }
        } else {
            for (
    nCounter 1nCounter <= 8nCounter++) {
                
    aXMA[nCounter] = aXMA_Ref[nCounter] + aSmoothingFactor[nCounter] * (close(0) - aXMA_Ref[nCounter]);
            }
        }        
      
     
        return new Array(
    aXMA[8], aXMA[7], aXMA[6], aXMA[5], aXMA[4], aXMA[3], aXMA[2], aXMA[1]); 
    }

    function 
    ClearArrays(){
        for (var 
    1<= 8i++) {
            
    aLength[i] = 0;
            
    aSmoothingFactor[i] = 0;
            
    aXMA[i] = 0;
            
    aXMA_Ref[i] = 1;
            
    aColor[i] = 0;
        }

Working...
X