Announcement

Collapse
No announcement yet.

2017 Apr: Volume-Weighted Moving Average by Ken Calhoun

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2017 Apr: Volume-Weighted Moving Average by Ken Calhoun

    File Name: VWMA_Breakouts.efs

    Description:
    Volume-Weighted Moving Average by Ken Calhoun

    Formula Parameters:

    VWMA_Breakouts.efs

    SMA Length: 70
    WVMA Length: 50

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

    Download File:
    VWMA_Breakouts.efs

    VWMA_Breakouts.efs


    EFS Code:
    PHP Code:
    /*********************************
    Provided By:  
    eSignal (Copyright c eSignal), a division of Interactive Data
    Corporation. 2016. 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:        
        Volume-Weighted Moving Average by Ken Calhoun

    Version:            1.00  02/10/2017

    Formula Parameters:                     Default:
    SMA Length                              70
    WVMA Length                             50



    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(true);
        
    setDefaultBarFgColor(Color.RGB(255,106,0),1);
        
    setCursorLabelName("SMA"0);
        
    setCursorLabelName("VWMA"1);
        var 
    x=0;
        
    fpArray[x] = new FunctionParameter("SMALength"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(1);
            
    setUpperLimit(1000);  
            
    setDefault(70);
            
    setName("SMA Length");
        }

        
    fpArray[x] = new FunctionParameter("VWMALength"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(1);
            
    setUpperLimit(1000);  
            
    setDefault(50);
            
    setName("VWMA Length");
        }
    }

    var 
    bInit false;
    var 
    bVersion null;
    var 
    bIsLong false;
    var 
    bWasLong false;
    var 
    xSMA null;
    var 
    xVWMA null;

    function 
    main(SMALengthVWMALength){

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


        if (
    getBarState() == BARSTATE_ALLBARS){
            
    bInit false;
        }

        if (!
    bInit){
            
    bIsLong false;
            
    bWasLong false;
            
    xSMA sma(SMALength);
            
    xVWMA vwma(VWMALength);
            
    bInit true;
        }
        if (
    xSMA.getValue(-1) == null || xVWMA.getValue(-1) == null) return;

        var 
    nSMA xSMA.getValue(0);
        var 
    nSMA_1 xSMA.getValue(-1);
        var 
    nVWMA xVWMA.getValue(0);
        var 
    nVWMA_1 xVWMA.getValue(-1);


        if (
    nSMA nVWMA && bIsLong){
            if (
    nSMA_1 <= nVWMA_1){
            
    drawTextRelative(0AboveBar1"\u00EA"Color.rednullText.PRESET|Text.CENTER"Wingdings"10"Exit"+rawtime(0));
            
    drawText("Suggested Long Exit",BottomRow1,Color.red,Text.LEFT,"TextExit"+rawtime(0));
            
    bIsLong false;
            }
            else {
                
    removeText("Long"+rawtime(0));
                
    removeText("Text"+rawtime(0));
            }
            
    bIsLong false;
        }

        if (!
    bIsLong && nSMA nVWMA){
            if (
    nSMA_1 nVWMA_1){
                
    drawTextRelative(0,BelowBar1"\u00E9"Color.greennullText.PRESET|Text.CENTER"Wingdings"10"Long"+rawtime(0));
                
    drawText("Suggested Long Entry",TopRow1,Color.green,Text.LEFT,"Text"+rawtime(0));
                
    bIsLong true;
                
    bWasLong true;
            }
            else {
                
    removeText("Exit"+rawtime(0));
                
    removeText("TextExit"+rawtime(0));
                if (
    bWasLong)
                    
    bIsLong true;
            }

        }

        return [
    nSMAnVWMA];
    }


    function 
    verify(){
        var 
    false;
        if (
    getBuildNumber() < 779){

            
    drawTextAbsolute(535"This study requires version 10.6 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