Announcement

Collapse
No announcement yet.

EFS Studies

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

  • #16
    Hi Macavity,

    Here is the Stochastic formula with an EMA instead of an SMA. Please let me if you have any further questions or require additional assistance.

    Code:
    /*********************************************
    Provided By	: TS Support, LLC for eSignal. (c) Copyright 2002  
    **********************************************/
    
    /////////////////////////// Inputs ////////////////////////////////////
    // nLength - indicates number of bars used in the Stochastic calculation
    // nSmoothing - indicates number of bars used for smoothing
    ////////////////////////////////////////////////////////////////////////
    
    function preMain()
    {
        setStudyTitle("Preferred Stochastic");
        setCursorLabelName("percentK", 0);
        setCursorLabelName("Smoothing", 1);
        setDefaultBarFgColor(Color.blue, 0);
        setDefaultBarFgColor(Color.red, 1);
        addBand(20, PS_SOLID, 1, Color.black);
        addBand(80, PS_SOLID, 1, Color.black);
    
    }
    var MAVt_1 = 0;
    function main(nLength, nSmoothing) {
        if(nLength == null)
            nLength = 5;
        if(nSmoothing == null)
            nSmoothing = 3;
    
        var percentK;
        var ll = 0, hh = 0;
        var i,j;
        var sum = 0;
        var vHigh = getValue("High", 0, -nLength);
        var vLow = getValue("Low", 0, -nLength);
        var temp = 0;
        var MAVt;
        
    	if(vHigh == null || vLow == null)
    		return;
    
    
    	for(j = 0; j < nLength; j++)
    		if(j == 0){
    			ll = vLow[j];	
    			hh = vHigh[j];
    		}
    		else{
    			hh = Math.max(hh, vHigh[j]);
    			ll = Math.min(ll, vLow[j]);
            	}
           
    	percentK = ((close() - ll) / (hh - ll)) * 100;
    	MAVt = MAVt_1 + (percentK - MAVt_1) / nSmoothing;
    	if (getBarState() == BARSTATE_NEWBAR)
    		MAVt_1 = MAVt;
    	return new Array(percentK,MAVt);
    }

    Comment


    • #17
      EFS Study # 9

      Our next indicator is Divergence Index.

      Oscillators > Divergence Index [eSignal EFS Indicators]

      Download: http://share.esignal.com/download.js...genceIndex.efs

      Category: Indicator > Miscellaneous

      Description:

      Divergence between market prices and an indicator applied to those prices can provide a strong signal of an impending price reversal. For example, when prices make new highs but the indicator does not, an important market top may be forming.

      This study is a way to measure divergence between price highs and an indicator to predict the strength of a new market top. This method could also be used to measure the divergence between price lows and an indicator to predict the strength of a new market bottom. In addition, instead of measuring the divergence between prices and an indicator, it could be used to measure the divergence between any two values - two different prices or even two different indicators.

      This study is calculating according to these formulas:

      Peak divergence = 50 x ((Hc-Hp)/(Hh-Hl))-((Ic-Ip)/(Ih-Il))

      where:

      Hc = High at the current peak.
      Hp = High at the previous peak
      Hh = Highest high from the previous to the current peak
      Hl = Lowest high from the previous to the current peak
      Ic = Indicator value at the current peak
      Ip = Indicator value at the previous peak
      Ih = Highest indicator value from the previous to the current peak
      Il = Lowest indicator value from the previous to the current peak

      Trough divergence = 50 x ((Ic-Ip)/(Ih-Il))-((Lc-Lp)/(Lh-Ll)),

      where:

      Ic = Indicator value at the current trough
      Ip = Indicator value at the previous trough
      Ih = Highest indicator value from the previous to the current trough
      Il = Lowest indicator value from the previous to the current trough
      Lc = Low at the current trough.
      Lp = Low at the previous trough
      Lh = Highest low from the previous to the current trough
      Ll = Lowest low from the previous to the current trough

      To get more information on this indicator, please read Quantifying Divergence With The Divergence Index by Matt Storz in 01/1996 issue of S&C magazine.



      No Inputs

      EFS Code:

      Code:
      /*******************************************************************
      Description : This Indicator plots DivergenceIndex indicator
      Provided By : Developed by TS Support, LLC for eSignal. (c) Copyright 2002
      ********************************************************************/
      
      function preMain()
      {
          setPriceStudy(false);
          setStudyTitle("Divergence Index");
          setCursorLabelName("PeakDivergence", 0);
          setCursorLabelName("TroughDivergence", 1);
          setDefaultBarFgColor(Color.blue, 0);
          setDefaultBarFgColor(Color.red, 1);
      }
      var Strength = 5;
      var Length = Strength + 1;
      var Occur = 1;
      var PeakDivergence = 0.0;
      var HpPeak = 0.0;
      var HcPeak = 0.0;
      var IpPeak = 0.0;
      var IcPeak = 0.0;
      var HhPeak = 0.0;
      var Val2Peak = 0.0;
      var HlPeak = 0.0;
      var Val3Peak = 0.0;
      var IhPeak = 0.0;
      var IlPeak = 0.0;
      var Val4Peak = 0.0;
      var Val5Peak = 0.0;
      var TroughDivergence = 0.0;
      var LpTrough = 0.0;
      var LcTrough = 0.0;
      var IpTrough = 0.0;
      var IcTrough = 0.0;
      var LhTrough = 0.0;
      var Val2Trough = 0.0;
      var LlTrough = 0.0;
      var Val3Trough = 0.0;
      var IhTrough = 0.0;
      var IlTrough = 0.0;
      var Val4Trough = 0.0;
      var Val5Trough = 0.0;
      var CurrentBar = 0;
      var UpAmt = 0.0;
      var DownAmt = 0.0;
      var UpAvg = 0.0;
      var DownAvg = 0.0;
      function main()
      {
          CurrentBar++;
          var Close = getValue("Close", 0, -20);
          var High = getValue("High", 0, -20);
          var Low = getValue("Low", 0, -20);
          var Found = false;
          var Counter = 0;
          var Price = null;
          var Price1 = 0.0;
          var Truth = false;
          var SwingHigh = 0.0;
          var SwingLow = 0.0;
          var RSI = new Array(Strength + 1);
          var UpSum = 0.0;
          var DownSum = 0.0;
          var x = 0;
          var i = 0;
          var j = 0;
          //SwingHigh
          j = Strength;
          Found = false;
          Price = High;
          if (j > 0)
          {
              Counter = 0;
              for (j = Strength; (j < Length)&&(Found == false); j++)
              {
                  Price1 = Price[j];
                  x = j + 1;
                  Truth = true;
                  for (x = j + 1; (Truth == true)&&((x - j) <= Strength); x++)
                  {
                      if (Price1 < Price[x]) Truth = false;
                  }
                  x = j - 1;
                  for (x = j - 1; (Truth == true)&&((j - x) <= Strength); x--)
                  {
                      if (Price1 <= Price[x]) Truth = false;
                  }
                  if (Truth == true)
                  {
                      Counter++;
                  }
                  if (Counter >= Occur) Found = true;
              }
          }
          if (Found == true) SwingHigh = Price1;
          else SwingHigh = -1;
          //SwingLow
          j = Strength;
          Found = false;
          Price = Low;
          if (j > 0)
          {
              Counter = 0;
              for (j = Strength; (j < Length)&&(Found == false); j++)
              {
                  Price1 = Price[j];
                  x = j + 1;
                  Truth = true;
                  for (x = j + 1; (Truth == true)&&((x - j) <= Strength); x++)
                  {
                      if (Price1 > Price[x]) Truth = false;
                  }
                  x = j - 1;
                  for (x = j - 1; (Truth == true)&&((j - x) <= Strength); x--)
                  {
                      if (Price1 >= Price[x]) Truth = false;
                  }
                  if (Truth == true) Counter++;
                  if (Counter >= Occur) Found = true;
              }
          }
          if (Found == true) SwingLow = Price1;
          else SwingLow = -1;
          //RSI
          Price = Close;
          for (j = 0; j < (Strength + 1); j++)
          {
              if (CurrentBar == 1)
              {
                  UpSum = 0.0;
                  DownSum = 0.0;
                  for (Counter = 0; Counter < 10; Counter++)
                  {
                      UpAmt = Price[Counter + j] - Price[Counter + j + 1];
                      if (UpAmt >= 0)
                      {
                          DownAmt = 0.0;
                      }
                      else
                      {
                          DownAmt = - UpAmt;
                          UpAmt = 0.0;
                      }
                      UpSum += UpAmt;
                      DownSum += DownAmt;
                  }
                  UpAvg = UpSum / 10;
                  DownAvg = DownSum / 10;
              }
              else if (CurrentBar > 1)
              {
                  UpAmt = Price[j] - Price[j + 1];
                  if (UpAmt >= 0) 
                  {
                      DownAmt = 0.0;
                  }
                  else
                  {
                      DownAmt = -UpAmt;
                      UpAmt = 0.0;
                  }
                  UpAvg = (UpAvg * 9 + UpAmt) / 10;
                  DownAvg = (DownAvg * 9 + DownAmt) / 10;
              }
              if ((UpAvg + DownAvg) != 0) RSI[j] = 100 * UpAvg / (UpAvg + DownAvg);
              else RSI[j] = 0;
          }
          //PeakDivergence
          if (SwingHigh != -1)
          {
              HpPeak = HcPeak;
              HcPeak = SwingHigh;
              IpPeak = IcPeak;
              IcPeak = RSI[Strength];
              HhPeak = Val2Peak;
              HlPeak = Val3Peak;
              Val2Peak = High[0];
              Val3Peak = High[0];
              IhPeak = Val4Peak;
              IlPeak = Val5Peak;
              Val4Peak = RSI[0];
              Val5Peak = RSI[0];
              for (i = 0; i <= Strength; i++)
              {
                  if (Val2Peak < High[i]) Val2Peak = High[i];
                  if (Val3Peak > High[i]) Val3Peak = High[i];
                  if (Val4Peak < RSI[i]) Val4Peak = RSI[i];
                  if (Val5Peak > RSI[i]) Val5Peak = RSI[i];
              }
          }
          if (High[0] > Val2Peak) Val2Peak = High[0];
          if (High[0] < Val3Peak) Val3Peak = High[0];
          if (RSI[0] > Val4Peak) Val4Peak = RSI[0];
          if (RSI[0] < Val5Peak) Val5Peak = RSI[0];
          if (((HhPeak - HlPeak) == 0)||((IhPeak - IlPeak) == 0)) PeakDivergence = PeakDivergence;
          else PeakDivergence = 50 * (((HcPeak - HpPeak) / (HhPeak - HlPeak)) - ((IcPeak - IpPeak) / (IhPeak - IlPeak)));
          //TroughDivergence
          if (SwingLow != -1)
          {
              LpTrough = LcTrough;
              LcTrough = SwingLow;
              IpTrough = IcTrough;
              IcTrough = RSI[Strength];
              LhTrough = Val2Trough;
              LlTrough = Val3Trough;
              Val2Trough = Low[0];
              Val3Trough = Low[0];
              IhTrough = Val4Trough;
              IlTrough = Val5Trough;
              Val4Trough = RSI[0];
              Val5Trough = RSI[0];
              for (i = 0; i <= Strength; i++)
              {
                  if (Val2Trough < Low[i]) Val2Trough = Low[i];
                  if (Val3Trough > Low[i]) Val3Trough = Low[i];
                  if (Val4Trough < RSI[i]) Val4Trough = RSI[i];
                  if (Val5Trough > RSI[i]) Val5Trough = RSI[i];
              }
          }
          if (Low[0] > Val2Trough) Val2Trough = Low[0];
          if (Low[0] < Val3Trough) Val3Trough = Low[0];
          if (RSI[0] > Val4Trough) Val4Trough = RSI[0];
          if (RSI[0] < Val5Trough) Val5Trough = RSI[0];
          if (((LhTrough - LlTrough) == 0)||((IhTrough - IlTrough) == 0)) TroughDivergence = TroughDivergence;
          else TroughDivergence = 50 * (((IcTrough - IpTrough) / (IhTrough - IlTrough)) - ((LcTrough - LpTrough) / (LhTrough - LlTrough)));
          return new Array(PeakDivergence, TroughDivergence);
      }

      Comment


      • #18
        TS Support,

        Have you coded the Ehlers Instantanaous Trend Line?
        If not, any plans to do so?

        Thanks,

        Garth
        Garth

        Comment


        • #19
          RVI?

          is there an els. for Relative Volitility Index?
          Thanks

          Comment


          • #20
            Garth,

            We've just coded Ehlers Instantanaous Trend Line for you. If you have any further questions or require additional assistance please reply to this topic. Here is the code:

            Code:
            /**********************************************
            Description	: This Indicator plots the Ehlers Instantanaous Trend Line
            Provided By	: TS Support, LLC for eSignal
            **********************************************/
            
            function preMain(){
                setStudyTitle("Ehlers Instantanaous Trend Line");
                setCursorLabelName("TR",0);
                setDefaultBarFgColor(Color.red,0);
                setCursorLabelName("ZL",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);
            }

            Comment


            • #21
              Wow! Thanks!

              Garth
              Garth

              Comment


              • #22
                Okay.. so...

                I subscribe to the MESA addon packages, and then people post the code for it ...

                The Ehlers Instantaneous Trendline is part of the MESA addon package.

                Hmm,
                Joshua C. Bergeron

                Comment


                • #23
                  Well there are a few thing here. One is that this code is based off of articles/books Ehlers has written, and I suspect that the MESA code is more tuned than the code descriptions given in the books/articles (he alludes to that in any case). It would be interesting to see if the results from the efs posted here are the same as those in MESA...I don't have MESA so I don't know but I suspect they will not be the same.

                  Second, MESA has a lot of other indicators...this is just one of many.
                  Garth

                  Comment


                  • #24
                    And here they all are, it seems.



                    That makes me a sad panda,
                    Joshua C. Bergeron

                    Comment


                    • #25
                      Joshua
                      It seems to me that those are just dll files similar to the ones that are already installed in the eSignal folder.
                      That does not imply that they are enabled.
                      Alex

                      Comment


                      • #26
                        Hi vcam6,

                        Here is the code for Relative Volitility Index you asked.

                        Code:
                        /*******************************************************************
                        Description	: This Indicator plots the Relative Volitility Index
                        Provided By	: TS Support, LLC for eSignal
                        ********************************************************************/
                        
                        function preMain(){
                            setStudyTitle("Relative Volitility Index");
                            setCursorLabelName("RVI",0);
                            setDefaultBarFgColor(Color.red,0);
                            addBand(30, PS_SOLID, 1, Color.grey);
                            addBand(70, PS_SOLID, 1, Color.grey);
                        
                        }
                        var U_1 = 0;
                        var D_1 = 0;
                        var ma = null;
                        
                        
                        function main(Period){
                        	if(Period == null)
                        		Period = 10;
                        	var StdDev = 0, u = 0, d = 0, U = 0, D = 0, SumSqr = 0;
                        	if(ma == null)
                        		ma = new MAStudy(Period, 0, "Close", MAStudy.SIMPLE);
                        
                        	for(counter = - Period + 1; counter <= 0; counter++)
                        		SumSqr += Math.pow((close(counter) - ma.getValue(MAStudy.MA)),2);
                        	StdDev = Math.sqrt(SumSqr / Period);
                        
                        	if(close() > close(-1)){
                        		u = StdDev;
                        		d = 0
                        	}
                        	else{
                        		d = StdDev;
                        		u = 0;
                        	}
                        	U = (13 * U_1 + u) / 14;
                        	D = (13 * D_1 + d) / 14;
                        	RVI = 100 * U / (U + D);
                        	if (getBarState() == BARSTATE_NEWBAR){
                        		U_1 = U;
                        		D_1 = D;
                        	}
                        
                        	return RVI;
                        }

                        Comment


                        • #27
                          Alex,

                          Oh. I see, I never noticed them in the ESignal folder.

                          But couldn't they be loaded by calling the DLL class? Or are there routines within the DLL that check if the user is subscribed to the package?

                          It's not too big of a deal anyway, I have stopped using the MESA indicators temporarily due to the problems I noted in another thread.

                          Sorry for the misunderstanding,

                          Joshua C. Bergeron

                          Comment


                          • #28
                            [Thanks TS.

                            Comment


                            • #29
                              EFS Study #12

                              Our next indicator is FVE (Finite Volume Elements).

                              Volume Based > FVE (Finite Volume Elements) [eSignal EFS Indicators]

                              Download: http://share.esignal.com/download.js...e_Katsanos.efs

                              Category: Indicator > Volume Based

                              Description:

                              The FVE is a pure volume indicator. Unlike most of the other indicators (except OBV), price change doesn’t come into the equation for the FVE (price is not multiplied by volume), but is only used to determine whether money is flowing in or out of the stock. This is contrary to the current trend in the design of modern money flow indicators. The author decided against a price-volume indicator for the following reasons:

                              - A pure volume indicator has more power to contradict.
                              - The number of buyers or sellers (which is assessed by volume) will be the same, regardless of the price fluctuation.
                              - Price-volume indicators tend to spike excessively at breakouts or breakdowns.

                              FVE is calculated by adding +V or subtracting -V from a running total of volume for the finite time element chosen (days, bars, weeks, and so on) according to whether:

                              C - (H + L)/2 + Typical - Typical(-1) > 0.3%C or < - 0.3%C, where:

                              C = Today’s closing price
                              H = Today’s high
                              L = Today’s low
                              Typical = (H+L+C)/3
                              Typical(-1) = Yesterday’s typical price.

                              The above inequality is derived by adding the following two inequalities:

                              C - (H + L)/2 > 0.15%C
                              (for intraday price action)

                              Typical - Typical(-1) > 0.15%C
                              (for interday price action)

                              The formula is normalized for all securities by dividing by the time period and simple moving average of the volume and multiplying by 100. Hence, FVE can vary between 100 and -100, although it seldom is outside the range of -80 to +80.

                              The final formula for FVE is:

                              FVE = SUM(1,t)([+V,-V,0/MA(V,t)]/t)*100

                              where:
                              t = Time segment chosen. The default is 22 days.
                              V = Volume. It can take a +/- sign or zero value according to inequality (1).
                              MA(V,t) = t day moving average of volume.

                              FVE gives two types of signals: the slope of FVI and the divergence between price and the indicator.

                              The most obvious and ordinary is the slope of the FVE line. An upward slope indicates the bulls are in control; a downward slope suggests the bears are in control.

                              The strongest signal, however, is the divergence between price and the indicator. This takes some time, at least a month, to develop on a daily chart. When FVE diverges from price, it shows that the current trend is becoming weak and is ready to reverse.



                              Inputs:

                              Period - number of bars to calculate indicator

                              EFS Code:

                              Code:
                              /*******************************************************************
                              Description	: This Indicator plots the Finite Volume Elements
                              Provided By	: TS Support, LLC for eSignal
                              ********************************************************************/
                              
                              function preMain(){
                                  setStudyTitle("Finite Volume Elements");
                                  setCursorLabelName("FVI",0);
                                  setDefaultBarFgColor(Color.red,0);
                              }
                              
                              var FVE = 0;
                              
                              function main(Period){
                              	if(Period == null)
                              		Period = 22;
                              	var MF = 0, vlm = 0, Sum = 0;
                              	
                              	MF = close() - (high() + low()) / 2 + (high() + low() + close()) /
                               3 - (high(-1) + low(-1) + close(-1)) / 3;
                              
                              	if(MF > .3 * close() / 100)
                              		vlm = volume();
                              	else if(MF < -.3 * close() / 100)
                              		vlm = - volume();
                              	else
                              		vlm = 0;	
                              		
                              	for(i = - Period + 1; i <= 0; i++)
                              		Sum += volume(i);
                              	VolumeMA = Sum / Period;
                              	
                              	if(getBarState() == BARSTATE_NEWBAR)
                              		FVE += ((vlm / VolumeMA) / Period) * 100;
                              	
                              	return FVE;
                              }
                              Last edited by TS Support; 03-04-2003, 11:05 AM.

                              Comment


                              • #30
                                TSSUPPORT,
                                Is there an adjustment i can make to the code of your laguerre based ma so that the lag ma it calculates on the 1 min chart is equal in value to the lagma on the 5 min chart.
                                In case what i just wrote confused you if i wanted to have the 20sma of the 5 minute chart on my one minute chart i simply need to change the 20 input to a 100sma.
                                Is there such an adjustment i can make to gamma value so that the lagueere ma i am placing on my 1 minute chart gives identical values to lagueere values on the 5 minute chart
                                Thanks
                                Yoda

                                Comment

                                Working...
                                X