Announcement

Collapse
No announcement yet.

Ehlers SNR

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

  • Ehlers SNR

    I would like to use this indicator that is written in Easy Language.
    Is there anyone who has converted this code or has the knowlege to help me please?
    Thanks!

    Inputs: Price((H+L)/2);

    Vars: Imult (.635),
    Qmult (.338),
    InPhase(0),
    Quadrature(0),
    Amplitude(0),
    Range(0);

    If CurrentBar > 8 then begin

    {Detrend Price}
    Value1 = Price - Price[7];

    {Compute "Noise" as the average range}
    Range = .2*(H - L) + .8*Range[1];

    {Compute Hilbert Transform outputs}
    Inphase = 1.25*(Value1[4] - Imult*Value1[2]) + Imult*InPhase[3];
    Quadrature = Value1[2] - Qmult*Value1 + Qmult*Quadrature[2];

    {Compute smoothed signal amplitude}
    Value2 = .2*(InPhase*InPhase + Quadrature*Quadrature) + .8*Value2[1];

    {Compute smoothed SNR in Decibels, guarding against a divide by zero error, and compensating for filter loss}
    If Value2 < .001 then Value2 = .001;
    If Range > 0 then Amplitude = .25*(10*Log(Value2/(Range*Range))/Log(10) + 1.9) + .75*Amplitude[1];

    {Plot Results}
    Plot1(Amplitude, "Amp");
    Plot2(6, "Ref");

    end;

  • #2
    Hello bigale,

    I have a couple questions as I'm not very familiar with ELA code.
    I assume that "Value1[4]" represents the value of Value1 from 4 bars ago. Is that correct?

    If yes, then it appears that the formulas for; Value1, Value2, InPhase, Quadrature and Amplitude are dependant on previous values of themselves. What are the formulas or methods used to prime the initial values? Please advise.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Hi JasonK,
      Thank you so much for your reply.
      To the best of my knowledge, your first assumption is correct.
      It seems as if the only EFS structures that support this notation are Open(), Low(), High() and Close(). To me, it seems like this would mean that the code is already written to reference a data value [n] bars ago and it is implemented in these functions.

      //My best guess as to how this would work would be as follows:
      //Value1 is initialized as follows:
      Value1=Close() - Close(-6)

      //If made as an array, we would initialize it like this:
      Value1(i) =Close() - Close(-6)

      //the max lookback period for Value1 is the value of itself 4 bars ago. i am guessing that this means we need to declare Value1 as an array with a dimension of 4

      //it is reference in the formulas by Value1[4], Value1[2],Value1
      //for each new bar up to 4 (increment counter for each bar to do this??), the values of Value1 are stored in the array Value1(counter) = Value1(1) through Value1(4), assuming a base one.

      //for the 5th value and each bar hence, the entire array is shifted, meaning Value(4) would be popped off of the stack and the Value1(1) becomes the latest bar (meaning Close() - Close(-6).

      //then we can reference Easy Language Value1 as EFS Array Value1(1) and EL Value1[2] = EFS Value1(2) etc...

      I am new to EFS, and could be way off here.

      I hope this helps.
      Thanks again!

      Comment


      • #4
        FYI:
        There is a post in this BBS that I came upon that calculates a different Ehlers Easy Language formula (Instantaneous Trend Line) and has been written in EFS.
        I think the post is called Ehlers ITL.
        I read the code, but didn't see if these "lookback structures" were something that is implemented. I don't have the original EL Code.
        Maybe this does something similar, but I couldn't figure it out.

        Comment


        • #5
          Yes TSSupport did the Ehlers ITL, he just saved the old values as needed, and recalculated on the fly by useing offsets to close sometimes as well (where it was a simple ROC type calc).

          You could use arrays and save all the data as well.

          Please be aware that the published formulas for Ehlers works are not as clean or accuaret as those that are provided by the MESA studies which can be added to eSignal for extra $.

          G
          Garth

          Comment


          • #6
            Hi bigale,

            Thanks for the details. The info for Value1 makes perfect sense. No problem there.

            However, we still need a priming method for Value2, Quadrature, InPhase and Amplitude. To better explain what I need let me use the Exponential Moving Average calculation as an example.

            The formula for EMA of the close:
            EMA = (((close() - EMA[1]) * dPercent) + EMA[1])

            dPercent is a constant and EMA[1] is the previous bar's EMA.

            As you can see here, the value of the current bar's EMA is dependant on the previous bar's EMA. Before we can get a valid number for this equation we have to have a starting value for the first EMA in the data series. For the EMA calculation, we use a simple moving average calculation for the first value of the data series. Then from the second bar in the series on, we can use the above formula because we will always have a valid value for the previous bar in the series. The simple moving average calculation "Primes" or begins our data series so that the second value in the series has a valid value for EMA[1] to reference. Hopefully this is clear enough.

            The formula for InPhase, for example, is similar to the EMA formula in that it is dependant on the previous bar's value of InPhase. How do you propose we prime the initial values for Value2, InPhase, Quadrature and Amplitude?
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment


            • #7
              Isn't that what the vars definition does?


              Imult (.635),
              Qmult (.338),
              InPhase(0),
              Quadrature(0),
              Amplitude(0),
              Range(0);

              I think it is fine that these are set to zero, as they don't do any finial multiplication or any division by these numbers. Therefore you will not get a constant zero (if a finial multiply) or an error (in any divide by zero).

              G
              Garth

              Comment


              • #8
                Hi G,

                That very well could be it. After looking at TS Support's itl.efs, it looks like they are priming the ITL with 0 values. Bigale, I'll put this formula together with 0 as the initial starting values and we'll see what happens.
                Jason K.
                Project Manager
                eSignal - an Interactive Data company

                EFS KnowledgeBase
                JavaScript for EFS Video Series
                EFS Beginner Tutorial Series
                EFS Glossary
                Custom EFS Development Policy

                New User Orientation

                Comment


                • #9
                  Ehlers SNR

                  Hi,

                  Good thread! I'm looking at using the Hilbert period as a lookback to create adaptive indicators and tried getting the period from the code in itl.efs.
                  However if I modify the efs to show either period or value5 it just shows me a constant 39 or 40.
                  What do I have to do to access the period?

                  Thanks
                  Phil

                  Comment


                  • #10
                    I did something similar only used the MESA indictators to pull the DC in realtime. According to Ehlers his calculation for the DC is much better then those published in his books and on the web. The results were less than amazing. I made an adaptive MACD, RSI and MOM and they didn't do too much better than their non adaptive counterparts - nor did they do as well as MESA during the same test periods.

                    I also remember that there was a bug or two in the ITL code from tss that I fixed - but I can't really remember what they were or what they affected...

                    G
                    Garth

                    Comment


                    • #11
                      Ohh I thought I had deleted my modifed copy of TSS ITL, but I still have it. Here it is...note I also change the calculation to work on HL/2 instead of close.
                      Attached Files
                      Garth

                      Comment


                      • #12
                        Garth,

                        I'll give your efs a try; I was wondering what it would give applied to Jurik's RSX.

                        Thanks
                        Phil

                        Comment


                        • #13
                          Hmmm... I suspect a bug; I've modified your efs to output the period and it gives a constant 39; you had a debug line commented out which I uncommented and that confirms the string of 39s. Finally I plotted a 39-period sma of (H+L)/2 and it looks identical to the instantaeous trendline.

                          Thanks
                          Phil

                          Comment


                          • #14
                            It could be. I took tss code and found a bug or two so I compared it to some EL code that did the same stuff I found online. That's how I figured out one of the errors in TSS code (the other one was an obvious one...I think it was a variable that was spelled wrong or similar).

                            But I'm not an EL expert...so it could be I misread what they were trying to do in the EL code, or even that the EL code was wrong to begin with.

                            I did compare the results from my modifed version of tss's code with some code that was later supplied to me from a 3rd party that did basically the same thing but used different methods. They produced results that were VERY similar...so if there was a bug, its a common one!

                            G
                            Garth

                            Comment


                            • #15
                              Hello bigale,

                              Your EL formula below for the Ehlers SNR is now converted to EFS. Again, this formula assumes that the initial values for some of the variables are primed with 0 values.

                              EhlersSNR.efs
                              Jason K.
                              Project Manager
                              eSignal - an Interactive Data company

                              EFS KnowledgeBase
                              JavaScript for EFS Video Series
                              EFS Beginner Tutorial Series
                              EFS Glossary
                              Custom EFS Development Policy

                              New User Orientation

                              Comment

                              Working...
                              X