Announcement

Collapse
No announcement yet.

Study on Study, efsExternal(?) as source for MACD

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

  • Study on Study, efsExternal(?) as source for MACD

    I'll start this off with a bit of a confession on my part. I started off about a month & 1/2 ago thinking I'd like to be able to run some study on study functions, in particular MACD studies with other studies as an input source. Prior to this, I have had zero experience with formula writing, efs scripting, Java Script, etc..... Nada, zip. I figured before I could ask any questions I should read what I could, see if I could figure it out myself, or lacking that, at least be able to ask the right questions to be able to get the answers I need. Well it's been over six weeks of going over this stuff and I'm still running into roads blocks so here goes...

    I decided the place to start was with modifying the "customMACD.efs" found in the EFS2 Custom folder; got it to how I want it and saved it in the Formula folder. A copy of the changes made are attached as "test1ModEFS2MACD.efs", original with notes of changes being made and why. Attachment "test2ModEFS2MACD.efs" is a cleaned up version minus the notes.

    The next step was to pick an efs2 formula I could use as a source for a MACD input. To keep it simple I used the customMA.efs found also in the EFS2 folder, with a minor adjustment, saved as the attachment "EFS2CustomMA.efs" and saved also in the Formula folder. I deliberately set it up as a 1 period SMA so I could easily confirm the final works outputs for accurracy, first with a 1 period, and then later changed to something else.

    Now's where I run into trouble. I have found several threads with topics about efsExternal, efsInternal, getseries, etc., and even a few with MACD used in explaining them with samples shown. I must be reading them wrong somehow because it always looks to me in the cases with MACD as if the samples are not really showing study on study using MACD with another efs source. I read them as a study's output being placed in a MACD study, following the PreMain with the source formula really generating the output and that output being passed to the MACD, but no MACD functions taking over and manipulating that output. I think this is often the case with the samples that have been made available. Maybe I just don't see it, I'm not sure.

    Any how, I've made several different attempts to get the above mentioned formulas to work together but I'm mostly taking shots in the dark without success. Half the time running the combined formulas results with a program crash. The attachment "MACDofCustomMA.efs" is my last attempt and it will crash the program.

    I suspect to correctly combine the formula's is probably pretty easy for someone who knows what they're doing. If so please, don't be bashful, step right up. I will very much appreciate it.
    My hope is to be able to grasp this concept of using one formula as a source for another. Thanks in advance to anyone that can help.

  • #2
    Trying to post the attachments again for below message
    Attached Files
    Last edited by rdanna; 08-18-2008, 08:03 PM.

    Comment


    • #3
      for some reason I can't load more than 1 attachment at a time,
      so.........
      Attached Files

      Comment


      • #4
        3 of 4
        Attached Files

        Comment


        • #5
          and 4 of 4
          Attached Files

          Comment


          • #6
            a quick search found this. Hope it helps

            Comment


            • #7
              Hello rdanna,

              First, thanks for posting your code.

              Another good thread to read is on this topic is; How easy are studies on studies in EFS2? by Alexis.

              Regarding your MACDofCustomMA.efs, the reason it crashes is because you're passing an EFS2 Series Object to the EFS1 legacy MACD study object. The EFS2 MACD function you need to use can be found here. The legacy EFS1 study objects are still available in EFS for backward compatibility reasons. If you are not sure you're using an EFS2 Series function, just remember that only EFS1 study objects are initialized with the "new" constructor. This constructor is not need for EFS2 series. Your bible for all things EFS2 are the current articles listed in the folder navigation of the EFS KnowledgeBase. In the Function reference folder, there are two categories that list all of the EFS2 series functions, Built-in Study Functions and Series Functions. The links provided point to the current list of functions for these two categories.

              For your code example, use the macd() and macdSignal() functions in place of the MACDStudy().

              macd( nFastLength , nSlowLength , nSmoothing [, Series | sym() | inv() ][, nBarIndex ] )

              PHP Code:
              var ExtEfs null;
              var 
              vMACD  null;
              var 
              vMACDSignal null;

              function 
              main(){
                  
                  if (
              ExtEfs == null) { // more efficient way to initialize your series objects.
                      
              ExtEfs efsExternal("EFS2CustomMA.efs");
                      
              //var myRet1 = getSeries(ExtEfs,0);
                      /*****
                          your EFS2CustomMA.efs only returns a single series, so the getSeries() 
                          call is not needed here.  Only use this to extract a return series 
                          from a formula that returns an array of series.
                      *****/
                      
              vMACD macd(12,26,9,ExtEfs);
                      
              vMACDSignal macdSignal(12,26,9,ExtEfs);
                  }
                  
                  
              //  These getValue() calls refer to the EFS1 study object members.
                  //return new Array(
                  //vMACD.getValue(MACDStudy.MACD),
                  //vMACD.getValue(MACDStudy.Signal)
                  //);
                  
                  // plot the macd() and macdSignal() series
                  
              return new Array(vMACD.getValue(0), vMACDSignal.getValue(0));

              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


              • #8
                JasonK.,

                Obviously, I'm very green when it comes to "EFS-speak".
                The time you took to look at my code, deduce my problem & provide the solution and reference links was terrific. Thank you so much for the help!

                I re-wrote the MACDofCustomMA efs as you recommended and post it below in case it may be informative to anyone else.

                Also, waynecd: Your link referred to info on the formula wizard. From what I understand the formula wizard is used with studies on studies that reference only builtin studies. The studies I'm using are not necessarily builtins; so I don't think I can use it. Funny, but if I could I think I and many others would be a lot happier. Ah well... but never the less, thank you too for offering some help.


                PHP Code:
                /***********************************************
                By Alexis C. Montenegro for eSignal © December 2004       
                Use and/or modify this code freely. If you redistribute it
                please include this and/or any other comment blocks and a 
                description of any changes you make.                      
                **********************************************************/

                /*Removed all MACD references for Histogram, & for my purposes
                  MACD parameters: "Source", "Symbol", & "Interval".  As per 
                  JasonK.'s instructions set this MACD study up with "EFS2CustomMA.efs"
                  as its source. */

                var fpArray = new Array();

                function 
                preMain() {

                    
                setStudyTitle("MACDofCustomMA");
                    
                setCursorLabelName("MACD",0);
                    
                setCursorLabelName("MACDSig",1);

                    
                setDefaultBarFgColor(Color.red,0); 
                    
                setDefaultBarFgColor(Color.blue,1);
                    
                    
                setPlotType(PLOTTYPE_LINE,0);
                    
                setPlotType(PLOTTYPE_LINE,1);
                    
                    
                setDefaultBarThickness(1,0);
                    
                setDefaultBarThickness(1,1);
                    
                    
                addBand(0,PS_SOLID,1,Color.yellow);
                    
                askForInput();
                    
                    var 
                x=0;
                    
                fpArray[x] = new FunctionParameter("Fast"FunctionParameter.NUMBER);
                    
                with(fpArray[x++]){
                        
                setLowerLimit(1);        
                        
                setDefault(12);
                    }
                    
                fpArray[x] = new FunctionParameter("Slow"FunctionParameter.NUMBER);
                    
                with(fpArray[x++]){
                        
                setLowerLimit(1);        
                        
                setDefault(26);
                    }
                    
                fpArray[x] = new FunctionParameter("Smoothing"FunctionParameter.NUMBER);
                    
                with(fpArray[x++]){
                        
                setLowerLimit(1);        
                        
                setDefault(9);
                    }       
                    
                fpArray[x] = new FunctionParameter("Params"FunctionParameter.BOOLEAN);
                    
                with(fpArray[x++]){
                        
                setName("Show Parameters");
                        
                setDefault(true);
                    }
                }

                var 
                ExtEfs null;
                var 
                vMACD  null;
                var 
                vMACDSignal null;

                function 
                main(Fast,Slow,Smoothing){
                    
                    if (
                ExtEfs == null) { // more efficient way to initialize your series objects.
                        
                ExtEfs efsExternal("EFS2CustomMA.efs");
                        
                //var myRet1 = getSeries(ExtEfs,0);
                        /*****
                            your EFS2CustomMA.efs only returns a single series, so the getSeries() 
                            call is not needed here.  Only use this to extract a return series 
                            from a formula that returns an array of series.
                        *****/
                        
                vMACD macd(Fast,Slow,Smoothing,ExtEfs);
                        
                vMACDSignal macdSignal(Fast,Slow,Smoothing,ExtEfs);
                    }
                    
                        
                    
                // plot the macd() and macdSignal() series
                    
                return new Array(vMACD.getValue(0), vMACDSignal.getValue(0));

                Comment


                • #9
                  You're most welcome.
                  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