Announcement

Collapse
No announcement yet.

Trix Fibbonacci Momentum Peak

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

  • Trix Fibbonacci Momentum Peak

    Hi everyone,

    Firstly, thanks and hats off to all the experienced coders who give their time and efforts and HELP to these threads!!

    My Question:

    Is it possible to create a MOMENTUM average of the TRIX, with a lookback of (1), ie: Trixmom= Today's Trix value - Yesterday's value and then creating a Momentum oscillator FibTrix by averaging three momentum Fib Periods of 8, 13, 21 , by using the amStudiesTEMA Formula?

    The formula should be : TrixFibPeak = (momofTEMA(8) + momof TEMA(13) + momTEMA(21) ) /3 based on a 13period lookback.

    This oscillator is an excellent tool for signaling reversals in the market.

    I've tried numerous times with the amTEMA.Studies, but I lack the knowlege in EFS script writng. The best I can do so far is a somewhat halfway cut and paste job of existing scripts...

    I'm still learning aspects of the new EFS2 and wondering if this code can be easily created by calling the amTema.efs from the amStudies Function Library?

    Any help of coding this would be greatly appriciated!!

    angelo
    ang.

  • #2
    Angelo
    The amTEMA in the amStudies library is not applicable to what you are trying to accomplish. That is a study by Patrick Mulloy based on the three individual EMAs used in the following equation
    TEMA = (3*EMA1)-(3*EMA2)+EMA3
    The TRIX instead is the difference between the current and prior value of a triple exponential average based on the natural log of the source ie
    TRIX = (TX(0)-TX(-1))*10000
    where TX = EMA(EMA(EMA,log(source)))
    The study you should use instead is the amTX() which is in the amBlauStudies library (see this post)
    To create the study you need to first call the library outside of function main ie
    var myLib = addLibrary("amBlauStudies.efsLib");
    Then create a separate function called for example "calc" which will calculate the log of the source (in the example shown below I use close(0)). This function will then be called with efsInternal as a source for the amTX() study

    PHP Code:
    function calc(){
        return 
    Math.log(close(0));

    At this point create another function called for example "trix" in which you calculate the TRIX.

    PHP Code:
    function trix(length1,length2,length3){
        var 
    study myLib.amTX(length1,length2,length3,efsInternal("calc"));
        if(
    study.getValue(-1)==null) return;//null check
        
    return (study.getValue(0)-study.getValue(-1))*10000;//equation for TRIX

    Once you have done that you have essentially created the TRIX study which you can then use as a source for your momentum study.
    So, in function main you define the three individual momentum studies each calling the "trix" function though efsInternal() while passing to it the different lengths

    PHP Code:
    var study1 mom(13,efsInternal("trix",8,8,8));
        
    //var study2 = same as above replacing the lengths to pass to "trix" with 13
        //repeat for study3 and pass 21 as the lengths 
    Run your null checks on each study ie if(study1.getValue(0)==null||study2.getValue..etc) and in the return statement of main you can perform your calculation ie
    return (study1.getValue(0)+study2.getValue..etc)/3;
    That should give you the study you are trying to create. Once the study is complete you will then want to optimize its efficiency by declaring the studies inside a bInit statement etc
    Alex

    Comment


    • #3
      Hi Alex,

      Thanks for an immediate response to my question!!
      Your knowledge is immeasurable , and your response as to showing how to construct the Trix formula was outstanding!!!!
      Many thanks again from a "newbee-wannabee". I'll try to construct this as best as possible!!

      As frustrated as I am in learning Java srcipt,(been trying since Feb 2005) I still have a LONG way to go in understanding what goes where and how, and when to use it....... and NOW its EFS2!

      Speaking of that, your last comment was to Optimize its efficiency by including it in a " bInt statement ." Please forgive me,I'm not sure what that means . Please explain.

      As for the the efficiency of the FibTrixPeak, (using the 8, 13, 21)periods, by it's nature, is it not already optimized? ....or am I shooting in the dark on this one???

      Also, one more thing.... if I want to use this new formula in a new script:
      1) do I call it as an efsExternal () or Internal() function
      2) as I understand it, I can place it in any formula subfolder file... yes/no?
      3) is the efsExternal()/ Internal() placed in Pre-Main() or can it be placed in Main()
      4) When is someone going to write a BOOK in PLAIN English to explain how to use all these wonderful tools in esignal????

      Again....I thank you for the reply .... and humbly ...I bow down to the" MENSA "group of knowledgable Moderators....

      angelo
      ang.

      Comment


      • #4
        angelo
        Thank you for the compliments and you are most welcome.
        When I referred to optimizing the efficiency of the study I was not referring to the indicator itself but to the efs.
        Here is a very basic example of what I meant. Let us assume you have an oscillator created by two simple moving averages

        PHP Code:
        function main(){

            var 
        Avg1 sma(10);
            var 
        Avg2 sma(21);

            if(
        Avg1.getValue(0)==null || Avg2.getValue(0)==null) return;

            var 
        Osc Avg1.getValue(0)-Avg2.getValue(0);

            return 
        Osc;

        As you can see I retrieve the value of both Avg1 and Avg2 twice, one time to perform the null check and the second while creating the oscillator. Instead of doing that I can improve the efficiency (albeit only marginally in this case) by retrieving the value once and assigning it to a variable which I then use throughout the rest of the script.

        PHP Code:
        function main(){

            var 
        Avg1 sma(10);
            var 
        Avg2 sma(21);
            
            var 
        nAvg1 Avg1.getValue(0);
            var 
        nAvg2 Avg2.getValue(0);
            
            if(
        nAvg1==null || nAvg2==null) return;

            var 
        Osc nAvg1-nAvg2;

            return 
        Osc;

        In both the examples above I am creating the two studies ie sma(10) and sma(20) and retrieving the series on every tick. Rather than doing that I could call them only once ie when they are first created as shown in the example below (where BTW you see my reference to bInit)

        PHP Code:
        var Avg1 null;
        var 
        Avg2 null;
        var 
        bInit false;

        function 
        main(){

            if(
        bInit==false){
                
        Avg1 sma(10);
                
        Avg2 sma(21);
                
        bInit=true;
            }
            
            var 
        nAvg1 Avg1.getValue(0);
            var 
        nAvg2 Avg2.getValue(0);
            
            if(
        nAvg1==null || nAvg2==null) return;

            var 
        Osc nAvg1-nAvg2;

            return 
        Osc;

        Again this is just a very basic example only to illustrate what I was referring to.
        For now I would suggest focusing on putting together the script and leaving this process to when you will have completed the efs
        Alex

        Comment


        • #5
          angelo
          Following up on my prior message with the replies to your questions
          1) You would call it using efsExternal()
          2) Yes
          3) The efsInternal and efsExternal() functions are in main (or as I showed in the example on how to create the TRIX in separate functions)
          4) That is a question that I cannot answer. Having said that there are at this time a lot of threads that include very complete examples of most of these EFS2 functions.
          Again thank you for the compliments
          Alex

          Comment


          • #6
            Hi Alex,

            Thanks for the returned responses to my questions. I see more clearly what I need to do and correct in my other written programs( esp. optimizing).

            Eventually, that small lightbulb in the grey matter begins to glow.... I see... Isee... I got it...I got it.....

            Till the next brain freeze...
            Angelo
            ang.

            Comment


            • #7
              Originally posted by Alexis C. Montenegro
              Angelo
              The amTEMA in the amStudies library is not applicable to what you are trying to accomplish. That is a study by Patrick Mulloy based on the three individual EMAs used in the following equation
              TEMA = (3*EMA1)-(3*EMA2)+EMA3
              Alex
              Where can I find this amTEMA formula in the amStudies library?

              I want to find an efs that will plot the Mulloy TEMA, the triple exponential moving average, but have come up with nothing after searching the the eSignal site and this forum.

              Comment


              • #8
                terrences
                See this thread
                Alex

                Comment

                Working...
                X