2011 Aug: Fibonacci And Lucas Automated Techniques For Intraday Traders

ICE Data Services -

FibLucasSeries.efs  
EFSLibrary - Discussion Board  

File Name: FibLucasSeries.efs

Description:
Fibonacci And Lucas Automated Techniques For Intraday Traders

Formula Parameters:

  • Fibonacci/Lucas: Fibonacci
  • Color: Color.lime
  • Select Start Date: First Bar On Chart
  • Start Date (mm/dd/yyyy): null
  • Start Time (hh:mm): 00:00

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

Download File:
FibLucasSeries.efs


EFS Code:

/*********************************
Provided By:  
    Interactive Data Corporation (Copyright © 2010) 
    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:        
    Fibonacci And Lucas Automated Techniques For Intraday Traders
	
Version:            1.00  14/06/2010

Formula Parameters:                     Default:
Fibonacci/Lucas                         Fibonacci
Color                                   Color.lime
Select Start Date                       First Bar On Chart
Start Date (mm/dd/yyyy)                 null
Start Time (hh:mm)                      00:00

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();
var barOffset = 0;
var bVersion = null;
function preMain() {

    setPriceStudy(true);
    setCursorLabelName("Last Value of Sequence");
    setPlotType(PLOTTYPE_FLATLINES);
    
    var x=0;
    fpArray[x] = new FunctionParameter("gFL", FunctionParameter.STRING);
    with(fpArray[x++]){
        setName("Fibonacci/Lucas");
        addOption("FIBONACCI"); 
        addOption("LUCAS"); 
        setDefault("FIBONACCI"); 
    }

    fpArray[x] = new FunctionParameter("gColor", FunctionParameter.COLOR);
    with(fpArray[x++]){
        setName("Color");
        setDefault(Color.lime); 
    }    
    
    fpArray[x] = new FunctionParameter("gFirstBar", FunctionParameter.STRING);
    with(fpArray[x++]){
        setName("Select Start Date");
        addOption("First Bar On Chart");
        addOption("User Defined");
        setDefault("First Bar On Chart"); 
    }
 
    fpArray[x] = new FunctionParameter("gDate", FunctionParameter.STRING);
    with(fpArray[x++]){
        setName("Start Date (mm/dd/yyyy)");
        setDefault(""); 
    }

    fpArray[x] = new FunctionParameter("gTime", FunctionParameter.STRING);
    with(fpArray[x++]){
        setName("Start Time (hh:mm)");
        setDefault("00:00"); 
    }
}

var bInit = false;
var startPos = 0;
var offsetBar = null;
var bFixColor = false;
var F1 = 5;
var F2 = 3;
var N = 1;
function main( gFL, gColor, gFirstBar, gDate, gTime )
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return; 

    if (getCurrentBarIndex() == 0 && getBarState() == BARSTATE_CURRENTBAR && bFixColor) setBarBgColor(gColor);
    
    if ( getBarState() == BARSTATE_ALLBARS )
    {

        F1 = 5;
        F2 = 3;
        N = 1;
        if  ( gFL == 'LUCAS' )
        {
            F1 = 3;
            F2 = 1;
            N = 1;
        }
        
        offsetBar = null;
        if ( gFirstBar !=  "User Defined" )  offsetBar = 0;
        else
        {
            var xDate = gDate.split("/");
            var xTime = (!isDWM()) ? gTime.split(":") : new Array("0","0");
            var startDate = new Date(xDate[2], xDate[0], xDate[1], xTime[0], xTime[1]);
            startPos = startDate.getTime();
        }
        if (offsetBar == 0)
        {
                setBarBgColor(gColor);
                drawTextRelative(0, BottomRow2, "Start" , gColor, null, Text.FRAME | Text.PRESET | Text.CENTER , "Arial", 11, "Start" );
                return "START";
        }
    }

    if ( getBarState() == BARSTATE_NEWBAR )
    {
        if ( isNull(offsetBar) )
        {    
            var currentDate = new Date(year(0), month(0), day(0), hour(0), minute(0));
            var currentPos = currentDate.getTime();
            if ( currentPos == startPos ) 
            {
                offsetBar = Math.abs(getOldestBarIndex() - getCurrentBarIndex()); 
                setBarBgColor(gColor);
                drawTextRelative(0, BottomRow2, "Start" , gColor, null, Text.FRAME | Text.PRESET | Text.CENTER , "Arial", 11, "Start" );
                return ("START");
            }
            if  ( currentPos > startPos  )
            {
                drawTextRelative(1, 20, " Date not availible ", Color.grey, null, Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.BOLD|Text.LEFT|Text.FRAME, null, 12, "dna");
                return ("Date not availible");
            }
        }
        else
        {
            if ( -getOldestBarIndex()-offsetBar-F1  == -getCurrentBarIndex() )
            {
                var b = F1;
                F1 +=F2;
                F2 = b; 
                N++;
                
                bFixColor = true;
                setBarBgColor(gColor);
                drawTextRelative(0, BottomRow3, " "+ N +" ", gColor, null, Text.FRAME | Text.PRESET | Text.CENTER , "Arial", 11, "N"+N );
                drawTextRelative(0, BottomRow2, F2+ " bars" , gColor, null, Text.FRAME | Text.PRESET | Text.CENTER , "Arial", 11, F2 );
                return ""+F2;
            }
            else
            {    
                bFixColor = false;
                var fromStart = -getOldestBarIndex()-offsetBar + getCurrentBarIndex(); 
                return ""+fromStart;
            }    
        }
    }    
} 


function verify() {
    var b = false;
    if (getBuildNumber() < 779) {
        drawTextAbsolute(5, 35, "This study requires version 8.0 or later.", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "error");
        drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp", 
            Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            null, 13, "upgrade");
        return b;
    } else {
        b = true;
    }
    return b;
}