Announcement

Collapse
No announcement yet.

AutoFIB

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

  • AutoFIB

    File Name: AutoFIB.efs

    Description:
    Displays Fibonacci levels automatically.

    ** Please note this study requires a subscription to the Advanced Get Studies.

    Formula Parameters:
    n/a

    Download File:
    AutoFIB.efs



    EFS Code:

    PHP Code:
    /************************
    Copyright © eSignal, 2003
    *************************

    Description: Displays Fibonacci levels automatically.

    ** Please note this study requires a subscription to the Advanced Get Studies.

    */

    var LINEMARGIN            5;
    var 
    RIGHTTEXT            true;

    function 
    preMain() {
        
    checkVersion(2"http://share.esignal.com/ContentRoot/PowerStation/MAG-EFS/AutoFIB.efs");

        
    addEntitlement("AGST""Not entitled for Advanced GET Studies");
        
    setStudyTitle("Auto FIB");
        
    setPriceStudy(true);
    }

    var 
    elliott = new GetElliottStudy(3000505350);

    var 
    nLastMRW        null// Last Most Recent Wave (used for reloading)
    var nLastMRWIndex   null;
    var 
    dLastMRWHigh    null;
    var 
    dLastMRWLow        null;

    var 
    arWaves        = new Array();
    var 
    arWaveBar        = new Array();
    var 
    bFibDrawn        false;

    function 
    dumpWaves() {
        
    debugPrintln("Dumping Waves");
        var 
    i;
        for(
    0arWaveBar.lengthi++) {
            
    debugPrintln("    Wave[" "]" arWaves[i] + " Index: " arWaveBar[i]);
        }
    }



    var 
    WAVE_A            7
    var WAVE_B            8
    var WAVE_C            9

    var WAVENOTFOUND        1// this is a bar index

    function isABC(nWave) {
        
    nWave Math.abs(nWave);
        if(
    nWave == || nWave == || nWave == 9)
            return 
    true;
        return 
    false;
    }



    function 
    findPriorWave(nWave) {
        var 
    i;

        if(
    arWaves.length == 0)
            return 
    WAVENOTFOUND;

        var 
    nStart arWaves.length-1;
        
    nStart--;
        for(
    nStart>= 0i--) {
            var 
    nWaveBar Math.abs(arWaves[i]);

            
    // If a 4 stop searching
            
    if(nWaveBar == || nWaveBar == WAVE_A || nWaveBar == WAVE_B)
                return 
    WAVENOTFOUND;

            if(
    nWaveBar == nWave)
                return 
    arWaveBar[i];
        }    

        return 
    WAVENOTFOUND;
    }

    function 
    findWavePriorToWave5(nWave) {
        var 
    i;

        if(
    arWaves.length == 0)
            return 
    WAVENOTFOUND;

        var 
    bTrigger false;
        var 
    nStart arWaves.length-1;
        
    nStart--;
        for(
    nStart>= 0i--) {
            var 
    nWaveBar Math.abs(arWaves[i]);
            
            if(
    bTrigger == true)
                break;

            
    // If a 4 stop searching
            
    if(nWaveBar == || nWaveBar == WAVE_C)
                
    bTrigger true;

            if(
    nWaveBar == nWave)
                return 
    arWaveBar[i];
        }    

        return 
    WAVENOTFOUND;
    }


    function 
    findWaveBeforeABC() {
        var 
    i;

        if(
    arWaves.length == 0)
            return 
    WAVENOTFOUND;

        var 
    nStart arWaves.length-1;
        
    nStart--;
        var 
    bTrigger false;
        for(
    nStart>= 0i--) {
            var 
    nWaveBar Math.abs(arWaves[i]);
            
            if(
    bTrigger == true) {
                return 
    arWaveBar[i];        
            }

            if(
    nWaveBar == WAVE_A
                
    bTrigger true;
            else if(
    nWaveBar WAVE_A)
                return 
    WAVENOTFOUND;

        }    

        return 
    WAVENOTFOUND;
    }

    function 
    findPriorWaveABC(nWave) {
        var 
    i;

        if(
    arWaves.length == 0)
            return 
    WAVENOTFOUND;

        var 
    nStart arWaves.length-1;
        
    nStart--;
        for(
    nStart>= 0i--) {
            var 
    nWaveBar Math.abs(arWaves[i]);

            
    // If a 4 stop searching
            
    if(nWaveBar WAVE_A)
                return 
    WAVENOTFOUND;

            if(
    nWaveBar == nWave)
                return 
    arWaveBar[i];
        }    

        return 
    WAVENOTFOUND;
    }


    function 
    findCurrentWave(nWave) {
        if(
    arWaves.length == 0)
            return 
    WAVENOTFOUND;

        var 
    nStart arWaves.length-1;
        var 
    nWaveBar Math.abs(arWaves[nStart]);

        if(
    nWaveBar == nWave)
            return 
    arWaveBar[nStart];

        return 
    WAVENOTFOUND;
    }


    function 
    findOnePriorWave(nWave) {
        if(
    arWaves.length 2)
            return 
    WAVENOTFOUND;

        var 
    nStart arWaves.length-1;
        var 
    nWaveBar Math.abs(arWaves[nStart-1]);

        if(
    nWaveBar == nWave)
            return 
    arWaveBar[nStart-1];

        return 
    WAVENOTFOUND;
    }


    function 
    getRetracement(dHdLdPercentnMRW) {
        if(
    nMRW 0) {
            return 
    dL - ((dL-dH) * dPercent);
        } else if(
    nMRW 0) {
            return 
    dL + ((dH-dL) * dPercent);
        }
        return 
    null;
    }
                    
    function 
    getExtension(dHdLdExtdPercentnMRW) {
        if(
    nMRW 0) {
            return 
    dExt + ((dL-dH) * dPercent);
        } else if(
    nMRW 0) {
            return 
    dExt - ((dH-dL) * dPercent);
        }
        return 
    null;
    }

    function 
    getHL(nBarbFirstnMRW) {
        if(
    nMRW 0) {
            if(
    bFirst) {
                return 
    low(nBar);
            } else {
                return 
    high(nBar);
            }
        } else if(
    nMRW 0) {
            if(
    bFirst) {
                return 
    high(nBar);
            } else {
                return 
    low(nBar);
            }
        }
        
        return 
    null;
    }


    function 
    addText(sTextnXdY) {
        if(
    RIGHTTEXT == true) {
            
    drawTextAbsolute(LINEMARGINdYsText
                
    Color.bluenull,
                
    Text.BOTTOM Text.LEFT Text.ONTOP Text.BOLD
                
    nullnullsText "-" getValue("rawtime"));
        } else {
            
    drawTextRelative(nXdYsText
                
    Color.bluenull,
                
    Text.BOTTOM Text.RIGHT Text.ONTOP Text.BOLD
                
    nullnullsText "-" getValue("rawtime"));
        }

    }

    function 
    getWaveColor(nWave) {
        if(
    nWave 0) {
            return 
    Color.red;
        } else if(
    nWave 0) {
            return 
    Color.lime;
        } 
        
        return 
    Color.black;
    }

    function 
    formatWave(nWave) {
        var 
    nRawWave nWave;
        
        
    nWave Math.abs(nWave);
        var 
    vRet "" nWave;
        if(
    nWave == WAVE_A
            
    vRet "A";
        else if(
    nWave == WAVE_B)
            
    vRet "B";
        else if(
    nWave == WAVE_C)
            
    vRet "C";
            
        return 
    vRet;
    }

    /****
    W2 Ret is measured from end of W5 to end of W1
    W3 Ext is based on measurement from end of W5 to end of W1 but starting the extension from end of W2
    W4 Ret is measured from end of W2 to end of W3
    W5 Ext is based on measurement from end of W5 to end of W3 but starting the extension from end of W4

    W2 is 0.50 to 0.75 retracement of W1 (up to 0.99)
    W3 is 1.618, 2.618, 4.25, 6.25 of W1 measured from end of W2
    W4 is 0.382 to 0.50 of W3 (up to 0.618)
    W5 is 0.618 of W1 to W3 measured from end of W4 (up to 1.00)

    Wave B is like W2
    Wave C is 1.00 of  WA measured from end of WB
    ***/

    function main() {
        
    // What's the most recent wave?  If it has changed since last remembered, reload the EFS.
        
    var nMRW elliott.getValue(GetElliottStudy.MOSTRECENTWAVE);
        var 
    nMRWIndex elliott.getValue(GetElliottStudy.MOSTRECENTWAVEBARINDEX);
        
        if(
    nMRWIndex == null)
            return;
            
        if(
    getCurrentBarIndex() == 0) {
            if(
    nLastMRW == null) {
                
    nLastMRW nMRW;
                
    nLastMRWIndex nMRWIndex;
                
    dLastMRWHigh high(nMRWIndex);
                
    dLastMRWLow low(nMRWIndex);

            } else if(
    nLastMRW != nMRW || nMRWIndex nLastMRWIndex || low(nMRWIndex) != dLastMRWLow || high(nMRWIndex) != dLastMRWHigh) {
                
    nLastMRW null;
                
    nLastMRWIndex null;
                
    dLastMRWHigh null;    
                
    dLastMRWLow null;

                
    reloadEFS();
                return;
            } else {
                
    nLastMRWIndex nMRWIndex;
                
    dLastMRWHigh high(nMRWIndex);
                
    dLastMRWLow low(nMRWIndex);
            }
        }


        var 
    nBarState getBarState();
        
    // If ALLBARS, init the wave arrays and vars.
        // If newbar, shift the bar indexes
        
    if(nBarState == BARSTATE_ALLBARS) {
            
    clearText();
            
    clearLineTool(LineTool.SEGMENT);
            
    arWaves.length        0;
            
    arWaveBar.length    0;
            
    bFibDrawn        false;
        } else if(
    nBarState == BARSTATE_NEWBAR) {
            
    // Get the current wave for a specific bar and add the wave and bar to the arrays
            
    var nWave elliott.getValue(GetElliottStudy.WAVE);
            if(
    nWave != null) {
                
    arWaves.push(nWave);
                
    arWaveBar.push(getCurrentBarIndex());
            }

        }


        
    // If on the most recent bar and the ellipses haven't been drawn, search for them
        // and draw them.
        // Should the MRW change, a reload will occur and this will re-execute.
        
    if(bFibDrawn == false && getCurrentBarIndex() == 0) {
            
    bFibDrawn true;
            
            
    // dumpWaves();
            // Use nMRW to determine which way to draw wave.

            
    drawTextAbsolute(115"CurWave: " formatWave(nMRW),
                
    Color.blackgetWaveColor(nMRW), 
                
    Text.RELATIVETOLEFT Text.RELATIVETOBOTTOM Text.FRAME Text.BOLD
                
    nullnull"OB");
            

            if(
    Math.abs(nMRW) == 3) {
                var 
    nBar1 findPriorWave(1);
                var 
    nBar2 findPriorWave(2);
                var 
    nBar5 findPriorWave(5);
                var 
    nBarC findPriorWave(WAVE_C);
                
                if(
    nBar5 == WAVENOTFOUND)
                    
    nBar5 nBarC;
                    
                if(
    nBar1 != WAVENOTFOUND && nBar2 != WAVENOTFOUND && nBar5 != WAVENOTFOUND) {
                    var 
    vH getHL(nBar5truenMRW);
                    var 
    vL getHL(nBar1falsenMRW);
                    var 
    v2 getHL(nBar2truenMRW);

                    
    addLineTool(LineTool.SEGMENTnBar5vH0vH1Color.black"tag");
                    
    addLineTool(LineTool.SEGMENTnBar5vL0vL1Color.black"tag");
                    
    addLineTool(LineTool.SEGMENTnBar1v20v21Color.black"tag");
                    
                    var 
    v1618 getExtension(vHvLv21.618nMRW);
                    var 
    v2618 getExtension(vHvLv22.618nMRW);
                    var 
    v425  getExtension(vHvLv24.25,  nMRW);
                    var 
    v625  getExtension(vHvLv26.25,  nMRW);

                    
    addLineTool(LineTool.SEGMENTnBar2v1618,  LINEMARGINv1618,  2Color.blue"tag");
                    
    addLineTool(LineTool.SEGMENTnBar2v2618,  LINEMARGINv2618,  2Color.blue"tag");
                    
    addLineTool(LineTool.SEGMENTnBar2v425,   LINEMARGINv425,   2Color.blue"tag");
                    
    addLineTool(LineTool.SEGMENTnBar2v625,   LINEMARGINv625,   2Color.blue"tag");

                    
    addText("1.618"nBar2v1618);                
                    
    addText("2.618"nBar2v2618);                
                    
    addText("4.25",  nBar2v425);                
                    
    addText("6.25",  nBar2v625);                
                    
                    
            
                }
            } else if(
    Math.abs(nMRW) == 4) { // 
                
    var nBar2 findPriorWave(2);
                var 
    nBar3 findPriorWave(3);
                
                if(
    nBar2 != WAVENOTFOUND && nBar3 != WAVENOTFOUND) {
                    var 
    vH getHL(nBar2truenMRW);
                    var 
    vL getHL(nBar3falsenMRW);
                    
                    
    addLineTool(LineTool.SEGMENTnBar2vHnBar3vH1Color.black"tag");
                    
    addLineTool(LineTool.SEGMENTnBar2vLnBar3vL1Color.black"tag");

                    var 
    v382 getRetracement(vHvL0.382nMRW);
                    var 
    v50  getRetracement(vHvL0.5nMRW);
                    var 
    v618 getRetracement(vHvL0.618nMRW);
                    
                    
    addLineTool(LineTool.SEGMENTnBar3v382LINEMARGINv3822Color.blue"tag");
                    
    addLineTool(LineTool.SEGMENTnBar3v50,  LINEMARGINv50,  2Color.blue"tag");
                    
    addLineTool(LineTool.SEGMENTnBar3v618LINEMARGINv6182Color.blue"tag");

                    
    addText("0.382"nBar3v382);                
                    
    addText("0.50",  nBar3v50);                
                    
    addText("0.618"nBar3v618);                
                
                }
                
            } else if(
    Math.abs(nMRW) == 5) {
                var 
    nBar3 findWavePriorToWave5(3);
                var 
    nBar4 findWavePriorToWave5(4);
                var 
    nBar5 findWavePriorToWave5(5);
                var 
    nBarC findWavePriorToWave5(WAVE_C);
                
                if(
    nBar5 == WAVENOTFOUND)
                    
    nBar5 nBarC;
                    
                if(
    nBar3 != WAVENOTFOUND && nBar4 != WAVENOTFOUND && nBar5 != WAVENOTFOUND) {
                    var 
    vH getHL(nBar5truenMRW);
                    var 
    vL getHL(nBar3falsenMRW);
                    var 
    v4 getHL(nBar4truenMRW);
                    
                    
                    
    addLineTool(LineTool.SEGMENTnBar5vHnBar3vH1Color.black"tag");
                    
    addLineTool(LineTool.SEGMENTnBar5vLnBar3vL1Color.black"tag");
                    
    addLineTool(LineTool.SEGMENTnBar3v4nBar4v41Color.black"tag");

                    var 
    v618 getExtension(vHvLv40.618nMRW);
                    var 
    v100 getExtension(vHvLv41.0nMRW);
                    
                    
    addLineTool(LineTool.SEGMENTnBar4v100LINEMARGINv100,  2Color.blue"tag");
                    
    addLineTool(LineTool.SEGMENTnBar4v618LINEMARGINv6182Color.blue"tag");

                    
    addText("1.0",      nBar4v100);
                    
    addText("0.618"nBar4v618);                
                    
                }

                
            } else if(
    Math.abs(nMRW) == WAVE_C) {
                var 
    nBarA findPriorWaveABC(WAVE_A);
                var 
    nBarB findPriorWaveABC(WAVE_B);
                
                if(
    nBarA != WAVENOTFOUND && nBarB != WAVENOTFOUND) {
                    var 
    nBarX findWaveBeforeABC();
                    
                    if(
    nBarX != WAVENOTFOUND) {
                        var 
    vH getHL(nBarXtruenMRW);
                        var 
    vL getHL(nBarAfalsenMRW);
                        var 
    vB getHL(nBarBtruenMRW);

                        
    addLineTool(LineTool.SEGMENTnBarXvHnBarAvH1Color.black"tag");
                        
    addLineTool(LineTool.SEGMENTnBarXvLnBarAvL1Color.black"tag");

                        var 
    v100 getExtension(vHvLvB1.00nMRW);
                        
                        
    addLineTool(LineTool.SEGMENTnBarBv100LINEMARGINv100,  2Color.blue"tag");
                        
    addText("1.0",      nBarBv100);
                        
                    }
                    
                }

            
            } else if(
    Math.abs(nMRW) == WAVE_B) {
            }




        }


        return;
        

    Regards,
    Jay F.
    Product Manager
    _____________________________________
    Have a suggestion to improve our products?
    Click Support --> Request a Feature in eSignal 11
Working...
X