Announcement

Collapse
No announcement yet.

EFS Studies

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

  • #61
    Re the efs below for exponential stochastics, I thought stochastic had 3 terms, number of bars, the fast ma and the slow ma, this one only seems to have two terms.

    Any idea on how to use that formula for a 14 bar interval with moving averages of 9 and 3?

    Comment


    • #62
      Call and Call Function

      I have read the stuff about Call and CallFunction and to be honest, I am not really any wiser.
      I took someone's advice in using CallFunction rather than Call but I have found that there is an issue when using CallFunction for the same ".efs" twice in function.

      I have a function.
      SDO - This is like MACD but I normalise it.
      It returns an array of 3 variables - (fast,slow,diff)
      SDO=SDO(12,26,9,55,8,1)
      The last argumment is a scaling argument done over the number of bars I usually use 1 or 5.
      For a routine - Indicator() - that I am writing I used CallFunction twice and was getting answers that did not match on my spreadsheet.

      I decided to look into and began testing parts seperately.
      I wrote the following in a "test.efs".

      **********************************
      main(){
      var SDO_1 = new Array();
      var SDO_2 = new Array();

      SDO_1=CallFunction("sdo.efs","main",12,26,9,55,8,1 );
      SDO_2=CallFunction("sdo.efs","main",12,26,9,55,8,5 );

      return SDO_1;
      }
      **********************************
      This returns me a different answer to my simple SDO function.
      However when I blank out the SDO_2 Call with "//", it returns the right answer.
      The second call (SDO_2) affects the first (SDO_1) basically.
      It does not even return the answer to SDO_2 instead, but is a completely different answer all together

      If I change CallFunction() for Call() I do not get this problem.

      Now I thought CallFunction() was better than Call() as it does not generate a new instance of the "sdo.efs", but this (the above) is crazy.
      As I said I read the article by MattG and it did not really clear things up to me.
      Call() appears to be a lot lower level, but to a VB programmer like myself using CallFunction() is like a simple public (library) function that should be able to be called as many times as I like without any intereference.
      Generating new instances (of anything) is usually not good practice as it does create memory overheads (usually later on down the line).

      I have double checked this and it appears to be the case.

      Could someone please explain what is going on?
      Is this a feature of CallFunction() that I have mistaken, or is there an issue with my "sdo.efs".

      I want to use the function (that calls the "sdo.efs" twice) in a BackTesting formula later on.
      I am worried that using Call() would produce a larger overhead on any routine; but using CallFunction() gives me gibberish.

      any ideas thanks

      macavity

      Comment


      • #63
        Call() and callFunction() - It gets worse!!

        Following on now.

        I wrote the following in a "test.efs".

        **********************************
        main(){
        var SDO_1 = new Array();
        var SDO_2 = new Array();

        SDO_1=callFunction("sdo.efs","main",12,26,9,55,8,1 );
        SDO_2=callFunction("sdo.efs","main",12,26,9,55,8,5 );

        return SDO_1;
        }

        This produces WRONG answers of SDO_1 ( a 3 element array), unless the "SDO_2=callFunction(..)" is blanked out

        Unfortuneatly if I replace callFunction() with Call() I cannot access the individual elements of the array returned.
        "SDO_1 has No Properties" - But it prints out all 3 to graph.

        e.g.

        var fast_1 = SDO_1[0];
        does not work with Call(), but does work with callFunction() - which unfortuneatly gives the wrong answer.

        If I can see all 3 elements on the Graph, why can I not access the elements in code.

        Sorry, but I find this whole JavaScript / ".efs" thing a right pain at the moment. It is painful to program with it, especially when you start writing complex routines.
        The behaviour of user-defined routines cannot be re-used with any degree of predictability of confidence as this above exercise is demonstrating.

        "How can I return a 3 element array to graph, but not have access to the elements in code?"

        I do write code, but I would have more luck re-learning assembler at this rate.

        "WHAT IS GOING ON?"

        -macavity

        Comment


        • #64
          Make sure you:

          1) Check for null returns in SDO for all calls of getValue
          2) return nulls to the calling program if you are erroring out due to null returns
          3) check for null returns from SDO in the calling program.

          I think if you do all of this you will get much better results.

          Garth
          Garth

          Comment


          • #65
            macavity
            I had the same exact problem where I was trying to use callFunction to access both the High and Low values from getTodayOHLC.efs and was only able to access one of them.
            While someone comes up with something better here is the extremely low tech solution I found.
            I made a copy of getTodayOHLC.efs and placed it in another folder (one could also make a second copy of it and leave it in the same folder with a different name).
            The interesting thing is that it appears considerably more responsive than having two separate call() to the same efs.
            Alex
            Last edited by ACM; 04-01-2003, 10:15 PM.

            Comment


            • #66
              Call() and callFunction()

              Gareth:

              Return Nulls.

              I checked this and I have even forced NULLS to be returned on all breaks etc.

              SDO: return new Array(null,null,null);

              Alexis :
              I think that you are right.
              I just discovered that the following actually works

              ************************************
              main(){
              var SDO_1 = new Array();
              var SDO_2 = new Array();

              SDO_1=CallFunction("library/sdo.efs","main",12,26,9,55,8,1);
              SDO_2=CallFunction("sdo.efs","main",12,26,9,55,8,5 );

              return SDO_1;
              }
              *************************************

              Sorry, but this is extremely ropey and bizzare.
              I will just copy SDO and rename a new version as you recommend.
              It seems safer.

              Garth, Alexis, thx for the help.

              If anyone from eSignal is reading this then please note.
              This is the sort of stuff that drives people nuts.
              This JavaScript / ".efs" does not behave like most languages I have seen.
              There are all these weird behaviours and no real way of finding out about it apart from bumbling along.
              There is something seriously wrong with Call() and callFunction() if changing the path (by mistake) sorts the problem.
              N.B.
              "library/sdo.efs.." works with "/library/sdo.efs...."
              Learning by Typos is a way to learn, but I would not recommend it going forward.
              We have the documentation but this stuff is not in it.

              Anyone had any luck writing and compiling .dll files in VB.
              This JavaScript stuff is really getting to me, it is odd as I do use it and VBScript a lot.

              Basically I am getting suspicious of using this methodology with TimeSeries data.
              "It is pants!"

              -macavity

              Comment


              • #67
                Return Nulls.
                I checked this and I have even forced NULLS to be returned on all breaks etc.
                This is odd. Usually when you see "SDO_1 has No Properties" type errors its because your arrays haven't been initialized yet because of a null return. The only other time I see it is when I access variables as arrays that I forgot to declare as an array myself...
                Garth

                Comment


                • #68
                  Stochastics and EMAs

                  I thought that I had posted this.

                  Basically the problems with slow-running stochastics, is that ".efs" is crap for long periods.

                  using the builtIn is quicker than using stochasticKK or stochasticDD for long periods ~ stochastic(50,20,1)

                  Basically if you write it yourself it will take ages for long periods.

                  1) Stochastic %K(sma), %D(sma) use builtIN.

                  2) Stochastic %K(ema), %D(ema)
                  function preMain()
                  {
                  setStudyTitle("StochXX");
                  setCursorLabelName("%K", 0);
                  setCursorLabelName("%D", 1);
                  setDefaultBarFgColor(Color.red, 0);
                  setDefaultBarFgColor(Color.blue, 1);
                  addBand(20, PS_SOLID, 1, Color.black);
                  addBand(80, PS_SOLID, 1, Color.black);

                  }

                  var MAVt_1 = 0;
                  var MAVt1_1 = 0;

                  function main(nLength, nPeriodK, nPeriodD)
                  {
                  if(nLength == null) nLength = 55;
                  if(nPeriodK == null) nPeriodK = 13;
                  if(nPeriodD == null) nPeriodD = 13;

                  var nBarState = getBarState();
                  var vStoch = new StochStudy(nLength, 1, 1)
                  var percentK;
                  var MAVt,MAVt1;

                  percentK = vStoch.getValue(StochStudy.FAST);
                  if (percentK == null) return;

                  MAVt = MAVt_1 + (percentK - MAVt_1) *(2/( nPeriodK+1));
                  MAVt1 = MAVt1_1 + (MAVt - MAVt1_1) *(2/( nPeriodD+1));
                  if (nBarState == BARSTATE_NEWBAR)
                  {
                  MAVt_1 = MAVt;
                  MAVt1_1 = MAVt1;
                  }
                  return new Array(MAVt,MAVt1);
                  }

                  3) Stochastic %K(sma), %D(ema)

                  function preMain() {

                  setStudyTitle("myStochSX");
                  setCursorLabelName("%K", 0);
                  setCursorLabelName("%D", 1);
                  setDefaultBarFgColor(Color.red, 0);
                  setDefaultBarFgColor(Color.blue, 1);
                  addBand(20, PS_SOLID, 1, Color.black);
                  addBand(80, PS_SOLID, 1, Color.black);

                  }
                  var dLastMA_Stoch = 0;
                  var dThisMA_Stoch = 0;

                  function main(Period,KLength,DLength)
                  {
                  if(Period == null) Period = 55;
                  if(KLength == null) KLength = 13;
                  if(DLength == null) DLength = 13;

                  var nBarState = getBarState();
                  var vStoch = new StochStudy(Period, KLength, 1);

                  var dfast;
                  var dslow;


                  dfast = vStoch.getValue(StochStudy.FAST);
                  if (dfast == null) return new Array(dfast, dslow) ;

                  if(nBarState == BARSTATE_NEWBAR)
                  {
                  dLastMA_Stoch = dThisMA_Stoch;
                  }
                  dThisMA_Stoch = ((dfast - dLastMA_Stoch) * (2.0 / (DLength + 1.0))) + dLastMA_Stoch;

                  dslow = dThisMA_Stoch;

                  return new Array(dfast,dslow);
                  }

                  - macavity

                  Comment


                  • #69
                    Return Nulls / No properties.

                    This was only a problem with Call(), callFunction() was fine - it just gave me the wrong answers.

                    I looked at SDO and there was no exit , no return without forcing it to return a 3 element null array.

                    As I am learning it is probably another random thing.

                    -macavity

                    Comment


                    • #70
                      CCI average?

                      Is there an EFS. for a CCI average?
                      Thank You.

                      Comment


                      • #71
                        vcam
                        If you mean a study that also plots an average of the CCI here is one that was originally created by JayF for RSI and that I have adapted for CCI.
                        To change the length of the CCI or of the Moving Average go to Edit Studies. Defaults are 20 and 3 respectively.
                        Alex
                        Attached Files
                        Last edited by ACM; 04-02-2003, 09:12 PM.

                        Comment


                        • #72
                          I am not sure but the ema stochastic formula below seemed to crash esignal on my pc. After I moved the var vStoch = new StochStudy(nLength, 1, 1) line out of main and placed it at the top of the file, the following didn't crash my pc

                          var vStoch = new StochStudy(55, 1, 1) //had to define nIterval here

                          function preMain()
                          {
                          setStudyTitle("StochXX");
                          setCursorLabelName("%K", 0);
                          setCursorLabelName("%D", 1);
                          setDefaultBarFgColor(Color.red, 0);
                          setDefaultBarFgColor(Color.blue, 1);
                          addBand(20, PS_SOLID, 1, Color.black);
                          addBand(80, PS_SOLID, 1, Color.black);

                          }

                          var MAVt_1 = 0;
                          var MAVt1_1 = 0;

                          function main(nLength, nPeriodK, nPeriodD)
                          {
                          if(nLength == null) nLength = 55;
                          if(nPeriodK == null) nPeriodK = 13;
                          if(nPeriodD == null) nPeriodD = 13;

                          var nBarState = getBarState();
                          //var vStoch = new StochStudy(nLength, 1, 1)
                          var percentK;
                          var MAVt,MAVt1;

                          percentK = vStoch.getValue(StochStudy.FAST);
                          if (percentK == null) return;

                          MAVt = MAVt_1 + (percentK - MAVt_1) *(2/( nPeriodK+1));
                          MAVt1 = MAVt1_1 + (MAVt - MAVt1_1) *(2/( nPeriodD+1));
                          if (nBarState == BARSTATE_NEWBAR)
                          {
                          MAVt_1 = MAVt;
                          MAVt1_1 = MAVt1;
                          }
                          return new Array(MAVt,MAVt1);
                          }

                          Comment


                          • #73
                            Apologies

                            Seems to work on mine.
                            I notice there is not a ";" after it when I pasted it.

                            -macavity

                            Comment


                            • #74
                              New EFS Study # 19

                              Averages > PFE (Polarized Fractal Efficiency) [eSignal EFS Indicators]

                              Download:

                              http://share.esignal.com/download.js...s&file=PFE.efs

                              Category: Fractals

                              Description:

                              The Polarized Fractal Efficiency (PFE) indicator measures the efficiency of price movements by drawing on concepts from fractal geometry and chaos theory. The more linear and efficient the price movement, the shorter the distance the prices must travel between two points and thus the more efficient the price movement.

                              The PFE indicator measures how trendy or congested the price action is. PFE readings above zero indicate that the trend is up. The higher the reading the "trendier" and more efficient the upward movement. PFE readings below zero mean that the trend is down. The lower the reading the "trendier" and more efficient the downward movement. Readings near zero indicate choppy, less efficient movement, with a balance between the forces of supply and demand. StockSpotter uses a short-term smoothed PFE with an intermediate lookback interval and produces buy/sell signals based on PFE threshold crossings.



                              No Inputs

                              EFS Code:

                              Code:
                              /*******************************************************************
                              Description	: This Indicator plots PFE (Polarized Fractal Efficiency) indicator
                              Provided By	: Developed by TS Support, LLC for eSignal. (c) Copyright 2002 
                              ********************************************************************/
                              
                              function preMain()
                              {
                                  setStudyTitle("Polarized Fractal Efficiency");
                                  setCursorLabelName("EMA", 0);
                                  setCursorLabelName("BUYZONE", 1);
                                  setCursorLabelName("SELLZONE", 2);
                                  setDefaultBarFgColor(Color.aqua, 0);
                                  setDefaultBarFgColor(Color.blue, 1);
                                  setDefaultBarFgColor(Color.red, 2);
                              }
                              var First = true;
                              var EMA = 0.0;
                              
                              var EMA_1 = 0.0;
                              function main()
                              {
                                  var PFE = 0.0;
                                  var C2C = 0.0;
                                  var Counter = 0;
                                  var FracEff = 0.0;
                                  var Close = getValue("Close", 0, -10);
                                  PFE = Math.sqrt(Math.pow((Close[0] - Close[9]),2) + 100);
                                  for (Counter = 1; Counter < 10; Counter++)
                                  {
                                      C2C += Math.sqrt(Math.pow((Close[Counter - 1] - Close[Counter]), 2) + 1);
                                  }
                                  if ((Close[0] - Close[9]) > 0) FracEff = Math.round((PFE / C2C) * 100);
                                  else FracEff = Math.round(-(PFE / C2C) * 100);
                                  if (First)
                                  {
                                      EMA = FracEff;
                                      First = false;
                                  }
                                  else EMA = Math.round(FracEff * 0.333 + EMA_1 * (1 - 0.333));
                                  if (getBarState() == BARSTATE_NEWBAR) EMA_1 = EMA;
                                  return new Array(EMA, 50, -50);
                              }

                              Comment


                              • #75
                                Re: Reply to post 'EFS Studies'

                                thx
                                ----- Original Message -----
                                From: <[email protected]>
                                To: <[email protected]>
                                Sent: Friday, March 28, 2003 6:29 PM
                                Subject: Reply to post 'EFS Studies'


                                > Hello macavity_katt,
                                >
                                > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                >

                                Comment

                                Working...
                                X