Announcement

Collapse
No announcement yet.

2014 Sep: Finding The Golden Triangle by Charlotte Hudgin

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

  • 2014 Sep: Finding The Golden Triangle by Charlotte Hudgin

    File Name: TheGoldenTriangleStrategy.efs

    Description:
    Finding The Golden Triangle by Charlotte Hudgin

    Formula Parameters:

    TheGoldenTriangleStrategy.efs
    Length SMA: 50
    Consider Days of White Space: 20
    Consider Days to Compare Volume: 0
    Entry Position Color: lime
    Exit Position Color: red

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

    Download File:
    TheGoldenTriangleStrategy.efs

    TheGoldenTriangleStrategy.efs


    EFS Code:
    PHP Code:

    /*********************************
    Provided By:  
        Interactive Data Corporation (Copyright В© 2014) 
        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:        
        Finding The Golden Triangle by Charlotte Hudgin

    Formula Parameters:                     Default:
    Length SMA                              50
    Consider Days of White Space            20
    Consider Days to Compare Volume         0
    Entry Position Color                    lime
    Exit Position Color                     red

    Version:            1.00  07/07/2014

    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("TheGoldenTriangleStrategy");
        
    setPriceStudy(true);
        
        
    setCursorLabelName("Moving Average"0);    

        var 
    0;

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

        
    fpArray[x] = new FunctionParameter("fpDaysWS"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Consider Days of White Space");
            
    setLowerLimit(1);
            
    setDefault(20);
        }

        
    fpArray[x] = new FunctionParameter("fpDaysVolume"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Consider Days to Compare Volume");    
            
    setLowerLimit(0);
            
    setDefault(0);
        }

        
    fpArray[x] = new FunctionParameter("fpEntryColor"FunctionParameter.COLOR);
        
    with(fpArray[x++]){
            
    setName("Entry Position Color");    
            
    setDefault(Color.lime);
        }

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

    var 
    bInit false;
    var 
    bVersion null;

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

    var 
    xPriceSMA null;
    var 
    xVolumeSMA null;
    var 
    xHignesVol null;

    var 
    nCurrDaysWS 0;
    var 
    nLotSize 0;

    var 
    bPriceConfirm false;
    var 
    bVolumeConfirm false;

    var 
    nPivotPrice null;

    function 
    main(fpLenSMAfpDaysWSfpDaysVolumefpEntryColorfpExitColor){
        
        if (
    bVersion == nullbVersion verify();
        if (
    bVersion == false) return;

        if (!
    bInit){
            
            
    xOpen open();
            
    xHigh high();
            
    xLow low();
            
    xClose close();
            
    xVolume volume();
            
            if (
    fpDaysVolume != 0)
                
    xHignesVol highest(fpDaysVolumexVolume);
                    
            
    xPriceSMA sma(fpLenSMA);
            
    xVolumeSMA sma(fpLenSMAxVolume);
            
            
    nLotSize Strategy.getDefaultLotSize();
            
            
    bInit true;
        }

        if (
    getBarState() == BARSTATE_ALLBARS){
            
    bPriceConfirm false;
            
    bVolumeConfirm false;
            
            
    nCurrDaysWS 0;
        };
                                
        var 
    nOpen xOpen.getValue(0);
        var 
    nHigh xHigh.getValue(0);
        var 
    nLow  xLow.getValue(0);
        var 
    nClose xClose.getValue(0);
        var 
    nPriorClose xClose.getValue(-1);
        var 
    nVolume xVolume.getValue(0);

        var 
    nPriceSMA xPriceSMA.getValue(0);
        var 
    nVolumeSMA xVolumeSMA.getValue(0);

        var 
    nHignesVol 0;

        if (
    fpDaysVolume != 0)    
            
    nHignesVol xHignesVol.getValue(-1);
           
        if (
    nPriorClose == null || nPriceSMA == null || nVolumeSMA == null || nHignesVol == null)
            return;
        
        if (
    getCurrentBarIndex() != 0){
            
            if (
    Strategy.isInTrade() && nHigh >= nPivotPrice){
            
                var 
    nExitPrice Math.max(nOpennPivotPrice);
                    
                
    Strategy.doSell("Exit"Strategy.LIMITStrategy.THISBARStrategy.DEFAULT, nExitPrice);
                
    drawShapeRelative(0AboveBar1Shape.DOWNTRIANGLEnull,
                
    fpExitColorText.PRESETgetCurrentBarIndex() + "Exit");
                
    drawTextRelative(0AboveBar2"Exit"fpExitColornull,
                
    Text.PRESET|Text.CENTERnullnullgetCurrentBarIndex() + "Exit");
                
    drawTextRelative(0AboveBar3nLotSize " @ " formatPriceNumber(nExitPrice),
                
    fpExitColornullText.PRESET|Text.CENTERnullnullgetCurrentBarIndex() + "ExitSettings"); 
                
                
    bPriceConfirm false;
                
    bVolumeConfirm false
            };
        
            if (!
    bPriceConfirm && nCurrDaysWS >= fpDaysWS && nLow <= nPriceSMA && nClose >= nPriceSMA){
            
                
    bPriceConfirm true;
                   
                for (var 
    0> -getCurrentBarCount()-1j--){
              
                    
    nPivotPrice xHigh.getValue(j-1);
                
                    if (
    xHigh.getValue(j) > xHigh.getValue(j-1)){
                        
    nPivotPrice xHigh.getValue(j);
                        break;
                    }
                } 
            
                if (
    nVolume nVolumeSMA && nVolume nHignesVol)
                    
    bVolumeConfirm true;
            };


            if (
    bPriceConfirm && !bVolumeConfirm){
                if (
    nVolume nVolumeSMA && nVolume nHignesVol && nClose nPriceSMA && nClose nPriorClose
                     
    bVolumeConfirm true;
            };
        
            if (
    bPriceConfirm && bVolumeConfirm && !Strategy.isInTrade()){
                
                var 
    nEntryPrice xOpen.getValue(1);
            
                if (
    nEntryPrice nPivotPrice){
                    
    bPriceConfirm false;
                    
    bVolumeConfirm false;
                } else{
                    
    Strategy.doLong("Entry"Strategy.MARKETStrategy.NEXTBARStrategy.DEFAULT);
                    
    drawShapeRelative(1BelowBar1Shape.UPTRIANGLEnull,
                    
    fpEntryColorText.PRESETgetCurrentBarIndex() + "Entry");
                    
    drawTextRelative(1BelowBar2"Entry"fpEntryColornull,
                    
    Text.PRESET|Text.CENTERnullnullgetCurrentBarIndex() + "Entry");
                    
    drawTextRelative(1BelowBar3nLotSize " @ " formatPriceNumber(nEntryPrice),
                    
    fpEntryColornullText.PRESET|Text.CENTERnullnullgetCurrentBarIndex() + "EntrySettings"); 
                };
            };
        };

        if (
    nLow nPriceSMA)
            
    nCurrDaysWS ++
        else
            
    nCurrDaysWS 0;
        
        
        return 
    nPriceSMA;
    }

    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