Announcement

Collapse
No announcement yet.

2009 Apr: Gardner Volatility, by Gerald Gardner

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

  • 2009 Apr: Gardner Volatility, by Gerald Gardner

    File Name: GardnerVolatility.efs

    Description:
    Profit With High Relative Strength Mutual Funds, by Gerald Gardner

    Formula Parameters:
    Volatility HOTFX Color : Blue
    Volatility FHYTX Color : Red
    Volatility HOTFX Color : Green
    Display Cursor Labels : True
    SMA Length For HOTFX : 10
    SMA Length For FHYTX : 20
    Line Thickness : 2

    Notes:
    The related article is copyrighted material. If you are not
    a subscriber of Stocks & Commodities, please visit www.traders.com.



    Download File:
    GardnerVolatility.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:        
        Profit With High Relative Strength Mutual Funds, by Gerald Gardner

    Version:            1.0  02/06/2009

    Formula Parameters:                     Default:
        Volatility HOTFX Color          Blue
        Volatility FHYTX Color          Red
        Volatility HOTFX Color          Green
        Display Cursor Labels           True
        SMA Length For HOTFX            10
        SMA Length For FHYTX            20
        Line Thickness                  2

    Notes:
        The related article is copyrighted material. If you are not
        a subscriber of Stocks & Commodities, please visit [url]www.traders.com.[/url]
        
    **********************************/

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

    function 
    preMain() {
        
    setPriceStudy(false);
        
    setShowCursorLabel(false);
        
    setShowTitleParametersfalse );
        
    setStudyTitle("Gardner Volatility");
        
    setCursorLabelName("Volatility HOTFX"0);        
        
    setCursorLabelName("Volatility FHYTX"1);    
        
    setCursorLabelName("Close - Avg"2);            
        
    setDefaultBarFgColor(Color.blue0);
        
    setPlotType(PLOTTYPE_HISTOGRAM0); 
        
    setDefaultBarThickness(20);
        
    setDefaultBarFgColor(Color.red1);
        
    setPlotType(PLOTTYPE_HISTOGRAM1); 
        
    setDefaultBarThickness(21);
        
    setDefaultBarFgColor(Color.green2);
        
    setPlotType(PLOTTYPE_HISTOGRAM2); 
        
    setDefaultBarThickness(22);
        
    askForInput();
        var 
    x=0;
        
    fpArray[x] = new FunctionParameter("LineColor1"FunctionParameter.COLOR);
        
    with(fpArray[x++]){
            
    setName("Volatility HOTFX Color");
            
    setDefault(Color.blue);
        }    
        
    fpArray[x] = new FunctionParameter("LineColor2"FunctionParameter.COLOR);
        
    with(fpArray[x++]){
            
    setName("Volatility FHYTX Color");
            
    setDefault(Color.red);
        }    
        
    fpArray[x] = new FunctionParameter("LineColor3"FunctionParameter.COLOR);
        
    with(fpArray[x++]){
            
    setName("Volatility HOTFX Color");
            
    setDefault(Color.green);
        }    
        
    fpArray[x] = new FunctionParameter("ViewValue"FunctionParameter.BOOLEAN);
        
    with(fpArray[x++]){
            
    setName("Display Cursor Labels");
            
    setDefault(true);
        }    
        
    fpArray[x] = new FunctionParameter("LengthHOTFX"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("SMA Length For HOTFX");
            
    setLowerLimit(1);        
            
    setDefault(10);
        }
        
    fpArray[x] = new FunctionParameter("LengthFHYTX"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("SMA Length For FHYTX");
            
    setLowerLimit(1);        
            
    setDefault(20);
        }
        
    fpArray[x] = new FunctionParameter("Thickness"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Line Thickness");
            
    setLowerLimit(1);        
            
    setDefault(2);
        }
    }

    var 
    xPrice_FHYTX null;
    var 
    xSMA20_FHYTX null;
    var 
    xStdDev20_FHYTX null;
    var 
    xSMA10_HOTFX null;
    var 
    xStdDev10_HOTFX null;

    function 
    main(LengthHOTFXLengthFHYTXLineColor1LineColor2LineColor3ThicknessViewValue) {
    var 
    nbdiffbuy 0;
    var 
    ndiffsell 0;
    var 
    nCloseGreaterSMA10 0;

        if (
    bVersion == nullbVersion verify();
        if (
    bVersion == false) return;   

        if ( 
    bInit == false ) { 
            
    setDefaultBarFgColor(LineColor10);
            
    setDefaultBarThickness(Thickness0);
            
    setDefaultBarFgColor(LineColor21);
            
    setDefaultBarThickness(Thickness1);
            
    setDefaultBarFgColor(LineColor32);
            
    setDefaultBarThickness(Thickness2);
            
    setShowCursorLabel(ViewValue);  
            
    xPrice_FHYTX close("FHYTX, D");
            
    xSMA20_FHYTX sma(20xPrice_FHYTX);
            
    xStdDev20_FHYTX efsInternal("StdDev"20xSMA20_FHYTX);
            
    xSMA10_HOTFX sma(10);
            
    xStdDev10_HOTFX efsInternal("StdDev"10close());
            
    bInit true
        } 

        if (
    xStdDev20_FHYTX.getValue(0) == null || xStdDev10_HOTFX.getValue(0) == null) return;
       
        
    ndiffbuy = (xPrice_FHYTX.getValue(0) - xSMA20_FHYTX.getValue(0)) / (xStdDev20_FHYTX.getValue(0));
        
    ndiffsell = (close(0) - xSMA10_HOTFX.getValue(0)) / (xStdDev10_HOTFX.getValue(0));
        
    nCloseGreaterSMA10 close(0) - xSMA10_HOTFX.getValue(0);
         
        if (
    Strategy.isLong()) {
            if (
    ndiffbuy < -&& ndiffsell < -1) {
                
    Strategy.doSell("Exit Long"Strategy.CLOSEStrategy.THISBAR);
                
    drawTextRelative(-10"Exit Long"Color.blackColor.redText.VCENTER Text.BOLD |  Text.PRESETnullnull"Txt" getValue("time"));
            }
        } else {
            if (
    ndiffbuy 1) {
                if (
    nCloseGreaterSMA10 0) {
                    
    Strategy.doLong("Enter Long"Strategy.MARKETStrategy.NEXTBAR);
                    
    drawTextRelative(-10"Long"Color.blackColor.limeText.VCENTER  Text.BOLD |  Text.PRESETnullnull"Txt" getValue("time"));
                }
            }
        }

        if (
    Strategy.isLong()) setBarBgColor(Color.lightgrey);
        
        return new Array(
    ndiffsellndiffbuynCloseGreaterSMA10); 
    }

    function 
    StdDev(nLengthxSeries) {
    var 
    sum 0;
    var 
    avg 0;
    var 
    res 0;
        if (
    xSeries.getValue(0) == null) return;
        for (var 
    barsBack nLength-1barsBack >= 0barsBack--) {
            
    sum += xSeries.getValue(barsBack*(-1));
        }
        
    avg sum nLength;
        
    sum 0;
        for (var 
    barsBack nLength 1barsBack >= 0barsBack--) {
            
    sum += (xSeries.getValue(barsBack*(-1))-avg)*(xSeries.getValue(barsBack*(-1))-avg);
        }
        
    res Math.sqrt(sum nLength);
        return 
    res
    }

    function 
    verify() {
        var 
    false;
        if (
    getBuildNumber() < 779) {
            
    drawTextAbsolute(535"This study requires version 8.0 or later."
                
    Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
                
    null13"error");
            
    drawTextAbsolute(520"Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp"
                
    Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
                
    null13"upgrade");
            return 
    b;
        } else {
            
    true;
        }
        return 
    b;

    Last edited by eSignal; 03-18-2009, 01:30 AM.
Working...
X