Announcement

Collapse
No announcement yet.

2016 Nov: Does Fully Automated Trading Software Work? by James Breen

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

  • 2016 Nov: Does Fully Automated Trading Software Work? by James Breen

    File Name: Trend_Following.efs

    Description:
    Does Fully Automated Trading Software Work? by James Breen

    Formula Parameters:

    Trend_Following.efs

    MALength: 10
    EntryTrigger%: 3
    ExitTrigger%: 4
    InitialStopLoss%: 2
    TrailingStopTrigger%: 6
    TrailingStop%: 2

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

    Download File:
    Trend_Following.efs

    Trend_Following.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:        
        Does Fully Automated Trading Software Work? by James Breen

    Version:            1.00  09/06/2016

    Formula Parameters:                     Default:
    MA Length                               10
    Entry Trigger %                         3
    Exit Trigger %                          4
    Initial Stop Loss %                     2
    Trailing Stop Trigger %                 6
    Trailing Stop %                         2



    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);
        
    setStudyTitle("MA");

        var 
    x=0;
        
    fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(1);
            
    setUpperLimit(1000);  
            
    setDefault(10);
            
    setName("MA Length");
        }

        
    fpArray[x] = new FunctionParameter("EntTrigger"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(0.1);
            
    setUpperLimit(100);
            
    setDefault(3);
            
    setName("Entry Trigger %");
        }

        
    fpArray[x] = new FunctionParameter("ExtTrigger"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(0.1);
            
    setUpperLimit(100);
            
    setDefault(4);
            
    setName("Exit Trigger %");
        }

        
    fpArray[x] = new FunctionParameter("InStopLoss"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(0.1);
            
    setUpperLimit(100);
            
    setDefault(2);
            
    setName("Initial Stop Loss %");
        }

        
    fpArray[x] = new FunctionParameter("TrlStopTrigger"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(0.1);
            
    setUpperLimit(100);
            
    setDefault(6);
            
    setName("Trailing Stop Trigger %");
        }

        
    fpArray[x] = new FunctionParameter("TrlStop"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(0.1);
            
    setUpperLimit(100);
            
    setDefault(2);
            
    setName("Trailing Stop %");
        }

        
    fpArray[x] = new FunctionParameter("MaxLoss"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(0);
            
    setDefault(500);
            
    setName("Max Daily Loss $");
        }
    }

    var 
    bInit false;
    var 
    bVersion null;
    var 
    xSMA null;
    var 
    xClose null;
    var 
    xHigh null;
    var 
    xLow null;
    var 
    nInv null;
    var 
    nShares 0;
    var 
    nEntryPrice 0;
    var 
    nTrlStop null;
    var 
    nHighestHigh null;
    var 
    nLowestLow null;
    var 
    nCumProfit 0;
    var 
    bMaxLost false;

    function 
    main(LengthEntTriggerExtTriggerInStopLossTrlStopTriggerTrlStopMaxLoss){

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

        if (
    getCurrentBarCount() <= Length) return;

        if (
    getBarState() == BARSTATE_ALLBARS){
            
    xSMA null;
            
    xClose null;
            
    xHigh null;
            
    xLow null;
            
    nInv null;
            
    nShares 0;
            
    nEntryPrice 0;
            
    nTrlStop null;
            
    nHighestHigh null;
            
    nLowestLow null;
            
    nCumProfit 0;
            
    bMaxLost false;
            
    bInit false;
        }

        if (!
    bInit){
            
    xClose close();
            
    xHigh high();
            
    xLow low();
            
    xSMA sma(LengthxClose);
            
    nHighestHigh xHigh.getValue(0);
            
    nLowestLow xLow.getValue(0);
            
    bInit true;
        }

        var 
    nSMA xSMA.getValue(0);
        var 
    nClose xClose.getValue(0);
        var 
    nHigh xHigh.getValue(0);
        var 
    nLow xLow.getValue(0);
        var 
    nTradeProfit 0;

        if (
    day(0) != day(-1) && !Strategy.isInTrade()){
            
    bMaxLost false;
            
    nCumProfit 0;
        }

        if (
    getCurrentBarIndex() != 0){
            if (
    Strategy.isLong())
                
    nTradeProfit nClose nShares nInv;
            else if (
    Strategy.isShort())
                
    nTradeProfit nInv nClose nShares;


            if ((
    nCumProfit nTradeProfit) <= -MaxLoss){
                if (
    Strategy.isLong())
                    
    Strategy.doSell("Loss Limit exceeded"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                else
                    
    Strategy.doCover("Loss Limit exceeded"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                
    nCumProfit 0;
                
    bMaxLost true;
            }

            if (
    nShares == 0)
                
    nShares Strategy.getDefaultLotSize();

            if (
    Strategy.isLong()){
                if (
    nTrlStop == null && (nHigh nShares) >= (nEntryPrice nShares * (TrlStopTrigger/100))){
                    
    nTrlStop nHigh * (TrlStop/100);
                    
    nHighestHigh nHigh;
                }

                if (
    nTrlStop != null && nHigh nHighestHigh){
                    
    nHighestHigh nHigh;
                    
    nTrlStop nHighestHigh * (TrlStop/100);
                }

                if (
    nClose < (nSMA * (ExtTrigger/100)))
                    
    Strategy.doSell("Exit Long"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                else if (
    nClose nShares < (nInv * (InStopLoss/100)))
                    
    Strategy.doSell("Stop Loss Long"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                else if (
    nTrlStop != null && nClose nTrlStop)
                    
    Strategy.doSell("Trl Stop Long"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);

                if (!
    Strategy.isLong()){
                    
    nCumProfit += nClose nShares nInv;
                    
    nTrlStop null;
                }


            }
            else if (
    Strategy.isShort()){
                    if (
    nTrlStop == null && (nLow nShares) <= (nEntryPrice nShares * (TrlStopTrigger/100))){
                    
    nTrlStop nLow * (TrlStop/100);
                    
    nLowestLow nLow;
                }

                if (
    nTrlStop != null && nLow nLowestLow){
                    
    nLowestLow nLow;
                    
    nTrlStop nLowestLow * (TrlStop/100);
                }
               if (
    nClose > (nSMA * (ExtTrigger/100)))
                    
    Strategy.doCover("Exit Short"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
               else if (
    nClose nShares > (nInv * (InStopLoss/100))){
                    
    Strategy.doCover("Stop Loss Short"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
               }
               else if (
    nTrlStop != null && nClose nTrlStop)
                    
    Strategy.doCover("Trl Stop Short"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);

               if (!
    Strategy.isShort()){
                
    nCumProfit += nInv nClose nShares;
                   
    nTrlStop null;
               }

           }

            if (!
    Strategy.isInTrade() && !bMaxLost){
                
    nTrlStop null;
                if (
    nClose > (nSMA * (EntTrigger/100))){
                    
    Strategy.doLong("Long"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                }
                else if (
    nClose < (nSMA * (EntTrigger/100))){
                    
    Strategy.doShort("Short"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT);
                }

                if (
    Strategy.isInTrade()){
                    
    nEntryPrice nClose;
                    
    nInv nShares nEntryPrice;
                }
            }

            if (
    Strategy.isLong()) setBarBgColor(Color.RGB(0,60,0));
            else if (
    Strategy.isShort()) setBarBgColor(Color.RGB(170,46,46))

        }

        if (
    nSMA != null) return  nSMA;
    }

    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