Announcement

Collapse
No announcement yet.

2013 Dec: Swing trading with three indicators by Donald Pendergast

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

  • 2013 Dec: Swing trading with three indicators by Donald Pendergast

    File Name: 3MA_TradingTemplate.efs

    Description:
    Swing trading with three indicators by Donald Pendergast

    Formula Parameters:

    3MA_TradingTemplate.efs
    Number of Ticks: 5
    EMA Length: 50
    Entry Long Position: lime
    Entry Short Position: red
    Exit Position: paleyellow

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

    Download File:
    3MA_TradingTemplate.efs


    3MA_TradingTemplate.efs


    EFS Code:
    PHP Code:

    /*********************************
    Provided By:  
        Interactive Data Corporation (Copyright © 2013) 
        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:        
        Swing trading with three indicators by Donald Pendergast
        
    Version:            1.00  10/07/2013

    Formula Parameters:                     Default:
    Number of Ticks                         5
    EMA Length                              50
    Entry Long Position                     lime
    Entry Short Position                    red
    Exit Position                           paleyellow

    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()
    {
        
    setStudyTitle("3MA_TradingTemplate");
        
    setPriceStudy(true);
        
        
    setCursorLabelName("MA(high)"0);
        
    setCursorLabelName("MA(low)"1);
        
    setCursorLabelName("EMA"2);
        
        
    setDefaultBarFgColor(Color.RGB(2551550), 0);
        
    setDefaultBarFgColor(Color.red1);
        
    setDefaultBarFgColor(Color.blue2);
        
        
    setDefaultBarThickness(20);
        
    setDefaultBarThickness(21);
        
    setDefaultBarThickness(22);
            
        var 
    0;

        
    fpArray[x] = new FunctionParameter("fpNumberTicks"FunctionParameter.NUMBER);
        
    with(fpArray[x++])
        {
            
    setName("Number of Ticks");
            
    setLowerLimit(1);
            
    setDefault(5);
        }

        
    fpArray[x] = new FunctionParameter("fpEMALength"FunctionParameter.NUMBER);
        
    with(fpArray[x++])
        {
            
    setName("EMA Length");
            
    setLowerLimit(1); 
            
    setDefault(50);
        }

        
    fpArray[x] = new FunctionParameter("fpEntryLongColor"FunctionParameter.COLOR);
        
    with(fpArray[x++])
        {
            
    setName("Entry Long Position");    
            
    setDefault(Color.lime);
        } 
        
        
    fpArray[x] = new FunctionParameter("fpEntryShortColor"FunctionParameter.COLOR);
        
    with(fpArray[x++])
        {
            
    setName("Entry Short Position");    
            
    setDefault(Color.red);
        }

        
    fpArray[x] = new FunctionParameter("fpExitColor"FunctionParameter.COLOR);
        
    with(fpArray[x++])
        {
            
    setName("Exit Position");    
            
    setDefault(Color.paleyellow  );
        }
    }

    var 
    bInit false;
    var 
    bVersion null;

    var 
    xClose null;
    var 
    xOpen null;
    var 
    xHigh null;
    var 
    xLow null;

    var 
    xMA_highs null;
    var 
    xMA_lows null;
    var 
    xEMA null;

    var 
    nTick 0;

    function 
    main(fpNumberTicksfpEMALengthfpEntryLongColorfpEntryShortColorfpExitColor
    {
        if (
    bVersion == nullbVersion verify();
        if (
    bVersion == false) return;
            
        if (!
    bInit)
        {
            
    xClose close();
            
    xOpen open();
            
    xHigh high();
            
    xLow low();
            
            
    xMA_highs sma(5xHigh);
            
    xMA_lows sma(5xLow);
            
    xEMA ema(fpEMALength);
            
            
    nTick getMinTick();
                    
            
    bInit true
        }

        var 
    nClose xClose.getValue(-1);
        var 
    nOpen xOpen.getValue(0);
        var 
    nHigh xHigh.getValue(0);
        var 
    nLow xLow.getValue(0);

        var 
    nMA_highs xMA_highs.getValue(0);
        var 
    nMA_lows xMA_lows.getValue(0);
        var 
    nEMA xEMA.getValue(0);

        if (
    nMA_highs == null || nMA_lows == null || nEMA == null)
            return;

        if (
    getCurrentBarIndex() != 0
        {
            var 
    bFStrategy Strategy.isInTrade();
            var 
    bLStrategy Strategy.isLong();
            var 
    bSStrategy Strategy.isShort();
            
            var 
    nLotSize Strategy.getDefaultLotSize();
            var 
    nFillPrice 0;
           
            if (!
    bFStrategy)
            {
                if ((
    nHigh nMA_highs + (fpNumberTicks nTick)) && (nClose nEMA))
                {
                    
    nFillPrice Math.max(nOpennMA_highs + (fpNumberTicks nTick));
                    
    Strategy.doLong("Enter Long"Strategy.STOPStrategy.THISBARStrategy.DEFAULT, nFillPrice);
                    
    drawTextRelative(0AboveBar3"Enter Long"Color.blackfpEntryLongColorText.PRESETnullnullgetCurrentBarIndex()+"action");
                    
    drawTextRelative(0AboveBar2nLotSize " @ " formatPriceNumber(nFillPrice), Color.blackfpEntryLongColorText.PRESETnullnullgetCurrentBarIndex()+"price");
                    
    drawShapeRelative(0AboveBar110nullColor.blueShape.PRESETnull); 
                }
                
                if ((
    nLow nMA_lows - (fpNumberTicks nTick)) && (nClose nEMA))
                {
                    
    nFillPrice Math.min(nOpennMA_lows - (fpNumberTicks nTick));
                    
    Strategy.doShort("Enter Short"Strategy.STOPStrategy.THISBARStrategy.DEFAULT, nFillPrice);
                    
    drawTextRelative(0AboveBar3"Enter Short"Color.blackfpEntryShortColorText.PRESETnullnullgetCurrentBarIndex()+"action");
                    
    drawTextRelative(0AboveBar2nLotSize " @ " formatPriceNumber(nFillPrice), Color.blackfpEntryShortColorText.PRESETnullnullgetCurrentBarIndex()+"price"); 
                    
    drawShapeRelative(0AboveBar110nullColor.blueShape.PRESETnull);
                }
            }
        
            if ((
    bLStrategy) && (nLow nMA_lows))
            {
                
    nFillPrice Math.min(nOpennMA_lows);
                
    Strategy.doSell("Exit Long"Strategy.STOPStrategy.THISBARStrategy.DEFAULT, nFillPrice);
                
    drawTextRelative(0BelowBar2"Exit Long"Color.blackfpExitColorText.PRESETnullnullgetCurrentBarIndex()+"action");
                
    drawTextRelative(0BelowBar3nLotSize " @ " formatPriceNumber(nFillPrice), Color.blackfpExitColorText.PRESETnullnullgetCurrentBarIndex()+"price"); 
                
    drawShapeRelative(0BelowBar19nullColor.blueShape.PRESETnull); 
            }
            
            if ((
    bSStrategy) && (nHigh nMA_highs))
            {
                
    nFillPrice Math.max(nOpennMA_highs);
                
    Strategy.doCover("Exit Short"Strategy.STOPStrategy.THISBARStrategy.DEFAULT, nFillPrice);
                
    drawTextRelative(0BelowBar2"Exit Short"Color.blackfpExitColorText.PRESETnullnullgetCurrentBarIndex()+"action");
                
    drawTextRelative(0BelowBar3nLotSize " @ " formatPriceNumber(nFillPrice), Color.blackfpExitColorText.PRESETnullnullgetCurrentBarIndex()+"price"); 
                
    drawShapeRelative(0BelowBar19nullColor.blueShape.PRESETnull); 
            }
        }

        return [
    nMA_highsnMA_lowsnEMA];
    }

    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;

Working...
X