Announcement

Collapse
No announcement yet.

2016 Feb: Higher Highs & Lower Lows by Vitali Apirine

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

  • 2016 Feb: Higher Highs & Lower Lows by Vitali Apirine

    File Name: HigherH_LowerL.efs

    Description:
    Higher Highs & Lower Lows by Vitali Apirine

    Formula Parameters:

    HigherH_LowerL.efs
    Highest/Lowest Lookback: 20
    Average Length: 20
    Overbought Level: 60
    Oversold Level: 10

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

    Download File:
    HigherH_LowerL.efs

    HigherH_LowerL.efs


    EFS Code:
    PHP Code:
    /*********************************
    Provided By:  
        Interactive Data Corporation (Copyright 2015) 
        All rights reserved. This sample eSignal Formula Script (EFS)
        is for educational purposes only. Interactive Data Corporation
        reserves the right to modify and overwrite this EFS file with 
        each new release. 

    Description:        
        Higher Highs & Lower Lows by Vitali Apirine

    Formula Parameters:                     Default:
    Highest/Lowest Lookback                 20
    Average Length                          20
    Overbought Level                        60
    Oversold Level                          10

    Version:            1.00  12/05/2015

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

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

    var fpArray = new Array();

    function 
    preMain(){
        
    setPriceStudy(false);
        
    setStudyTitle("Higher Highs & Lower Lows");
        
    setCursorLabelName("HHS",0);
        
    setCursorLabelName("LLS",1);
        
    setDefaultBarFgColor(Color.RGB(0,148,255),0);
        
    setDefaultBarFgColor(Color.RGB(255,155,0),1);
        
        var 
    x=0;
        
    fpArray[x] = new FunctionParameter("Lookback"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Highest/Lowest Lookback");
            
    setLowerLimit(1);        
            
    setDefault(20);
        }
        
    fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Avgerage Length");
            
    setLowerLimit(1);        
            
    setDefault(20);
        }
        
    fpArray[x] = new FunctionParameter("OB"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Overbought Level");
            
    setLowerLimit(0);
            
    setUpperLimit(100);  
            
    setDefault(60);
        }
        
    fpArray[x] = new FunctionParameter("OS"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Oversold Level");
            
    setLowerLimit(0);
            
    setUpperLimit(100);  
            
    setDefault(10);
        }
    }

    var 
    xHS_LS null;
    var 
    xHHS null;
    var 
    xLLS null;
    var 
    bVersion null;

    function 
    main(LookbackLengthOBOS){
        
        if (
    bVersion == nullbVersion verify();
        if (
    bVersion == false) return;
        
        if(
    getBarState() == BARSTATE_ALLBARS){
            
    xHS_LS efsInternal("calc"Lookback);
            
    xHHS ema(LengthgetSeries(xHS_LS,0));
            
    xLLS ema(LengthgetSeries(xHS_LS,1));
            
    addBand(OB,PS_SOLID,1,Color.lightgrey,"OB");
            
    addBand(OS,PS_SOLID,1,Color.lightgrey,"OS");
        }
        
        var 
    nHHS xHHS.getValue(0);
        var 
    nLLS xLLS.getValue(0);

        if(
    nHHS == null || nLLS == null) return;
        
        return [
    nHHSnLLS]
    }

    var 
    xHigh null;
    var 
    xLow null;
    var 
    xHighestH null;
    var 
    xLowestH null;
    var 
    xHighestL null;
    var 
    xLowestL null;
    var 
    bInit false;

    function 
    calc(Lookback){
        
        if(!
    bInit){
            
    xHigh high();
            
    xLow low();
            
    xHighestH hhv(LookbackxHigh);
            
    xLowestH llv(LookbackxHigh);
            
    xHighestL hhv(LookbackxLow);
            
    xLowestL llv(LookbackxLow);
            
    bInit true;
        }
        
        var 
    nHigh xHigh.getValue(0);
        var 
    nHigh_1 xHigh.getValue(-1);
        var 
    nLow xLow.getValue(0);
        var 
    nLow_1 xLow.getValue(-1);
        var 
    nHighestH xHighestH.getValue(0);
        var 
    nLowestH xLowestH.getValue(0);
        var 
    nHighestL xHighestL.getValue(0);
        var 
    nLowestL xLowestL.getValue(0);

        if(
    nHigh_1 == null || nLow_1 == null || nHighestH == null || nLowestH == null || 
           
    nHighestL == null || nLowestL == null)
            return;
        
        var 
    HS nHigh nHigh_1? (nHigh-nLowestH)/(nHighestH-nLowestH)*1000;
        var 
    LS nLow nLow_1? (nHighestL-nLow)/(nHighestL-nLowestL)*1000;

        return [
    HS,LS]
    }

    function 
    verify(){
        var 
    false;
        if (
    getBuildNumber() < 3742){
            
            
    drawTextAbsolute(535"This study requires version 12.1 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;

Working...
X