Announcement

Collapse
No announcement yet.

Ehler's ITL and $VIX

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ehler's ITL and $VIX

    For the Ehlers ITL, I would like to have the background green in indicator screen when xover up, and background red in same screen when it xover down. Code is below.
    Also, is there a $vix efs?
    Thank you.







    /**********************************************
    Description : This Indicator plots the Ehlers Instantanaous Trend Line
    Provided By : TS Support, LLC for eSignal
    **********************************************/

    function preMain(){
    setStudyTitle("EITL");
    setCursorLabelName("EITL",0);
    setDefaultBarFgColor(Color.red,0);
    setCursorLabelName("EITL",1);
    setDefaultBarFgColor(Color.blue,1);
    }
    var InPhase_1 = 0;
    var Quadrature_1 = 0;
    var Phase_1 = 0;
    var InstPeriod = 0;
    var value5_1 = 0;
    var value11_1 = 0;
    Delta = new Array();


    function main(){
    var value1 = 0, value2 = 0, value3 = 0, value4 = 0, value5 = 0, value11 = 0, InPhase = 0, Quadrature = 0, Phase = 0, Deltaphase = 0, InstPeriod = 0, Trendline = 0, Period = 0;

    if(getCurrentBarIndex() - getOldestBarIndex() > 5){
    value1 = close() - close(-6);
    value2 = close(-3) - close(-9);
    value3 = .75 * (value1 - (close(-6) - close(-12)) ) + .25 * ( (close(-2) - close(-8)) - (close(-4) - close(-10)) );
    InPhase = .33 * value2 + .67 * InPhase_1;
    Quadrature = .2 * value3 + .8 * Quadrature_1;

    //Use ArcTangent to compute the current phase
    if(Math.abs(InPhase + InPhase_1) > 0)
    Phase = Math.atan(Math.abs( (Quadrature + Quadrature_1) / (InPhase + InPhase_1) ));

    //Resolve the ArcTangent ambiguity
    if(InPhase < 0 && Quadrature > 0)
    Phase = 180 - Phase;
    if(InPhase < 0 && Quadrature < 0)
    Phase = 180 + Phase;
    if(InPhase > 0 && Quadrature < 0)
    Phase = 360 - Phase;

    //Compute a differential phase, resolve phase wraparound, and limit delta phase errors
    DeltaPhase = Phase_1 - Phase;

    if(Phase_1 < 90 && Phase > 270)
    DeltaPhase = 360 + Phase_1 - Phase;
    if(DeltaPhase < 1)
    DeltaPhase = 1;
    if(DeltaPhase > 60)
    Deltaphase = 60;

    //Sum DeltaPhases to reach 360 degrees. The sum is the instantaneous period
    for(i = 40; i > 0; i--)
    Delta[i] = Delta[i - 1];
    Delta[0] = Deltaphase;
    InstPeriod = 0;
    Value4 = 0;
    for(i = 0; i <= 40; i++){
    value4 += Delta[i];
    if(value4 > 360 && InstPeriod == 0)
    InstPeriod = i;
    }

    //Resolve Instantaneous Period errors and smooth
    if(InstPeriod == 0)
    InstPeriod = InstPeriod_1;
    value5 = .25 * InstPeriod + .75 * value5_1;

    //Compute Trendline as simple average over the measured dominant cycle period
    if(value5 < 0){
    tmp = - value5;
    Period = - Math.floor(tmp);
    }
    else
    Period = Math.floor(value5);

    Trendline = 0;
    for(i = Period + 1; i >= 0; i--)
    Trendline += close(-i);

    if(Period > 0)
    Trendline = Trendline / (Period + 2);
    value11 = .33 * (close() + .5 * (close() - close(-3))) + .67 * value11_1;
    }

    if (getBarState() == BARSTATE_NEWBAR){
    InPhase_1 = InPhase;
    Quadrature_1 = Quadrature;
    Phase_1 = Phase;
    InstPeriod_1 = InstPeriod;
    value5_1 = value5;
    value11_1 = value11;
    }

    return new Array(Trendline,value11);
    }
    Michael

  • #2
    michael
    I think this does what you want
    Alex





    /**********************************************
    Description : This Indicator plots the Ehlers Instantanaous Trend Line
    Provided By : TS Support, LLC for eSignal
    **********************************************/

    var vLastAlert = -1;

    function preMain(){
    setStudyTitle("EITL");
    setCursorLabelName("EITL",0);
    setDefaultBarFgColor(Color.red,0);
    setCursorLabelName("EITL",1);
    setDefaultBarFgColor(Color.blue,1);
    }
    var InPhase_1 = 0;
    var Quadrature_1 = 0;
    var Phase_1 = 0;
    var InstPeriod = 0;
    var value5_1 = 0;
    var value11_1 = 0;
    Delta = new Array();


    function main(){
    var value1 = 0, value2 = 0, value3 = 0, value4 = 0, value5 = 0, value11 = 0, InPhase = 0, Quadrature = 0, Phase = 0, Deltaphase = 0, InstPeriod = 0, Trendline = 0, Period = 0;

    if(getCurrentBarIndex() - getOldestBarIndex() > 5){
    value1 = close() - close(-6);
    value2 = close(-3) - close(-9);
    value3 = .75 * (value1 - (close(-6) - close(-12)) ) + .25 * ( (close(-2) - close(-8)) - (close(-4) - close(-10)) );
    InPhase = .33 * value2 + .67 * InPhase_1;
    Quadrature = .2 * value3 + .8 * Quadrature_1;

    //Use ArcTangent to compute the current phase
    if(Math.abs(InPhase + InPhase_1) > 0)
    Phase = Math.atan(Math.abs( (Quadrature + Quadrature_1) / (InPhase + InPhase_1) ));

    //Resolve the ArcTangent ambiguity
    if(InPhase < 0 && Quadrature > 0)
    Phase = 180 - Phase;
    if(InPhase < 0 && Quadrature < 0)
    Phase = 180 + Phase;
    if(InPhase > 0 && Quadrature < 0)
    Phase = 360 - Phase;

    //Compute a differential phase, resolve phase wraparound, and limit delta phase errors
    DeltaPhase = Phase_1 - Phase;

    if(Phase_1 < 90 && Phase > 270)
    DeltaPhase = 360 + Phase_1 - Phase;
    if(DeltaPhase < 1)
    DeltaPhase = 1;
    if(DeltaPhase > 60)
    Deltaphase = 60;

    //Sum DeltaPhases to reach 360 degrees. The sum is the instantaneous period
    for(i = 40; i > 0; i--)
    Delta[i] = Delta[i - 1];
    Delta[0] = Deltaphase;
    InstPeriod = 0;
    Value4 = 0;
    for(i = 0; i <= 40; i++){
    value4 += Delta[i];
    if(value4 > 360 && InstPeriod == 0)
    InstPeriod = i;
    }

    //Resolve Instantaneous Period errors and smooth
    if(InstPeriod == 0)
    InstPeriod = InstPeriod_1;
    value5 = .25 * InstPeriod + .75 * value5_1;

    //Compute Trendline as simple average over the measured dominant cycle period
    if(value5 < 0){
    tmp = - value5;
    Period = - Math.floor(tmp);
    }
    else
    Period = Math.floor(value5);

    Trendline = 0;
    for(i = Period + 1; i >= 0; i--)
    Trendline += close(-i);

    if(Period > 0)
    Trendline = Trendline / (Period + 2);
    value11 = .33 * (close() + .5 * (close() - close(-3))) + .67 * value11_1;
    }

    if (getBarState() == BARSTATE_NEWBAR){
    InPhase_1 = InPhase;
    Quadrature_1 = Quadrature;
    Phase_1 = Phase;
    InstPeriod_1 = InstPeriod;
    value5_1 = value5;
    value11_1 = value11;
    }

    if (value11>Trendline)
    onAction1()
    else if (value11<Trendline)
    onAction2();

    return new Array(Trendline,value11);
    }

    function onAction1(){
    if (vLastAlert != 1) setBarBgColor(Color.lime)
    vLastAlert = 1;
    }
    function onAction2(){
    if (vLastAlert != 2) setBarBgColor(Color.red)
    vLastAlert = 2;
    }

    Comment


    • #3
      thanks very much, alex. would prefer the BGcolor to extend until next xover, rather than just for a bar.

      also, any answer to the $vix efs question? i am looking for a $vix efs indicator.
      Michael

      Comment


      • #4
        michael
        No problem. Go to the very end of the formula and substitute

        this line
        if (vLastAlert != 1) setBarBgColor(Color.lime)
        with this
        setBarBgColor(Color.lime)

        and this line
        if (vLastAlert != 2) setBarBgColor(Color.red)
        with this
        setBarBgColor(Color.red)

        At this point you will need to also change the color of the red plot.
        That should be in Line 11 of the formula.
        Change the line from this
        setDefaultBarFgColor(Color.red,0);
        to this (just as an example)
        setDefaultBarFgColor(Color.black,0);

        As to $vix.efs the reply will have to come from someone else.
        Alex

        Comment


        • #5
          perfect...gracias.
          Michael

          Comment


          • #6
            i've found a $vix indicator via $HighFive stuff, fyi.
            Michael

            Comment

            Working...
            X