Announcement

Collapse
No announcement yet.

Sum of two studies using Formula Wizard

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

  • Sum of two studies using Formula Wizard

    Hi everyone:

    I am using the Formula Wizard currently to back my way into learning EFS code (that is, by building the formula and then studying the code so that I can write it myself in the EFS editor later).

    The study I want to build is actually the sum of a momentum study and a moving average study. I notice (or at least I cannot find a counter-example of such) that one cannot write a sum of two studies within the Formula Wizard.

    Is this true? If not, how does one include addition of studies into the Formula Wizard to create a Non-Price Study?

    Also, if there is a printer output for the Formula Wizard code (outside of printing the screen), I would like to know how to do that.

    Thank you for your assistance.
    buffalotrader100

  • #2
    dbuffalo

    I notice (or at least I cannot find a counter-example of such) that one cannot write a sum of two studies within the Formula Wizard. Is this true?
    If you just want to sum the indicators and plot the result or use it in a condition then you can write the equation in the Returned Data Points section or in the condition line (see the attached example) . You will need to completely enclose the equation in parenthesis to prevent the Formula Wizard's syntax checker from modifying it.
    Alex

    Attached Files

    Comment


    • #3
      Thanks again. I am going to integrate this into the current formula structure and produce more code. If I have problems I will post the code so that you will have context.
      buffalotrader100

      Comment


      • #4
        dbuffalo
        You are most welcome.
        Alex

        Comment


        • #5
          Alexis:

          I decided to perform a brute force variable application (because at some point I am going to broaden the use of that CFGMO1 variable to some delagging mechanisms for trade entries with futures.

          Here is the problem (and it is probably caused by my ignorance of variable naming or coding conventions). When I defined CFGMO1 as a variable below, a check of the syntax brings back the following error:

          \CFGMO1.efs line 14: MAStudy parameter 3 invalid

          Is the fact that I created a variable out of the sum of two other variables (and that it really isn't a new study but just a calculation) that the EFS compiler cannot understand it?

          What should I do to fix that?

          Thanks again for your help.

          dbuffalo






          //{{EFSWizard_Description
          //
          // This formula was generated by the Alert Wizard
          //
          //}}EFSWizard_Description


          //{{EFSWizard_Declarations
          var vRSI3 = new RSIStudy(3, "Close");
          var vSMA3_of_vRSI3 = new MAStudy(3, 0, vRSI3, MAStudy.SIMPLE);
          var vRSI14 = new RSIStudy(14, "Close");
          var vMOM9_of_vRSI14 = new MOMStudy(9, vRSI14);
          var vCFGMO1 = vMOM9_of_vRSI14 + vSMA3_of_vRSI3;
          var vSMA3_of_vCFGMO1 = new MAStudy(3, 0, vCFGMO1, MAStudy.SIMPLE);
          var vLastAlert = -1;
          //}}EFSWizard_Declarations


          function preMain() {
          /**
          * This function is called only once, before any of the bars are loaded.
          * Place any study or EFS configuration commands here.
          */
          //{{EFSWizard_PreMain
          setPriceStudy(false);
          setStudyTitle("CFGMO1");
          setCursorLabelName("CFGMO1", 0);
          setCursorLabelName("vSMA3_of_vCFGMO1", 1);
          setDefaultBarStyle(PS_SOLID, 0);
          setDefaultBarStyle(PS_SOLID, 1);
          setDefaultBarFgColor(Color.red, 0);
          setDefaultBarFgColor(Color.blue, 1);
          setDefaultBarThickness(1, 0);
          setDefaultBarThickness(2, 1);
          setPlotType(PLOTTYPE_LINE, 0);
          setPlotType(PLOTTYPE_LINE, 1);
          //}}EFSWizard_PreMain

          }

          function main() {
          /**
          * The main() function is called once per bar on all previous bars, once per
          * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
          * in your preMain(), it is also called on every tick.
          */

          //{{EFSWizard_Expressions
          //{{EFSWizard_Expression_1
          //}}EFSWizard_Expression_1

          //}}EFSWizard_Expressions


          //{{EFSWizard_Return
          return new Array(
          vMOM9_of_vRSI14 + vSMA3_of_vRSI3,
          vSMA3_of_vCFGMO1.getValue(MAStudy.MA)
          );
          //}}EFSWizard_Return

          }

          function postMain() {
          /**
          * The postMain() function is called only once, when the EFS is no longer used for
          * the current symbol (ie, symbol change, chart closing, or application shutdown).
          */
          }

          //{{EFSWizard_Actions
          //{{EFSWizard_Action_1
          function onAction1() {
          vLastAlert = 1;
          }
          //}}EFSWizard_Action_1

          //}}EFSWizard_Actions
          buffalotrader100

          Comment


          • #6
            dbuffalo
            You cannot do what you are trying to accomplish using the efs1 functions. This is because the efs1 functions cannot use custom variables (such as vCFGMO1) as the source. Those functions can only use a price series (ie "High", "Low", "Close", etc) and in some cases another built-in study.
            To do what you want you will need to use the efs2 functions which can use a price series, another built-in study or a custom series as a source.
            To create a custom series you need to perform your calculations in a separate function or external efs and then retrieve the results of those calculations using the efsInternal() or efsExternal() functions This series can then be used as a source for the built-in studies.
            For the description of the efsInternal() and efsExternal() functions and the required syntax see the links above which will take you to the corresponding articles in the EFS KnowledgeBase.
            You can also find several detailed examples on how to use efsInternal() and efsExternal() in this and this thread.
            Alex

            Comment


            • #7
              Alexis:

              Now that I have time once again to do programming, I am still a little confused as to how I would use efs Internal() or efs External() functions to define a value which can be used in another efs study.

              I understand what the simple variables are like vRSI3=new RSIStudy (3, “Close”); is.

              What I do not understand is how to use efs Internal to define another variable.

              If I were trying to calculate the sum of two other variables, then it would seem that I would have to define two separate variables and (if I understand it correctly) then call the values back up in the efs Internal() or eft External(). Yet, none of these expressions contain variables.

              The entire logic of this function escapes me. I am used to using Technifilter Plus, which uses a much more elegant way of storing values and adding them back into other variables (though it does not have quite the same plotting features as E-Signal). It does not require any constant re-referencing of variables or values (as it stores them within memory).

              If I could just understand what needs to be pulled into the function, I could probably understand how to use it. Putting an expression (like the “IE/2” example) inside the efs Internal doesn’t mean anything if that expression is not a variable. It could just be that I don’t understand what is being defined by the expression in quotations.

              Can you help with this? Also, would it help me to go to a community college and take a course in programming? If so, which language would you suggest I study to get a handle on the EFS language?

              I am a mathematician but I am not up to speed on programming as I once was. I have a vast array of studies I would like to test, but I find the ability to program them easily is not really available with my skill level.

              Thank you again for your help.
              buffalotrader100

              Comment


              • #8
                dbuffalo
                The primary function of efsInternal() and efsExternal() is to allow you to call another function or efs and retrieve the values returned by that function or efs.
                In doing this the efsInternal() and efsExternal() functions create a data series which can be used either on its own or as a custom source for another function (eSignal built-in or otherwise).
                For some basic examples on how to use efsInternal() and efsExternal() you may want to see this thread.
                With regards to learning how to program in efs I would suggest that you start by reviewing the JavaScript for EFS video series and the Core JavaScript Reference Guide. Those will provide you with a thorough introduction to programming in JavaScript which is at the foundation of EFS. Then go through the EFS KnowledgeBase and study the Help Guides and Tutorials which will provide you with the specifics of EFS.
                Alex

                Comment


                • #9
                  Alexis:

                  Thanks for that extra information.

                  I am also reading a book about Javascript ( Beginning Javascript - 2nd Edition by Paul Wilton), which is helping me understand basic structure. I think my biggest problem is that I do not understand the basic elements of the objects (functions, etc. in the context of object-oriented programming).

                  I think once I get to the math calculation part of this book, the light will go on and I will be able to understand the structure and finally ask some intelligent questions.

                  I refuse to quit until I can get to backtesting my own models in E-Signal.

                  Thanks again for all the help.
                  buffalotrader100

                  Comment


                  • #10
                    Quick question...I could type them in myself (and I will if there is no alternative), but I noticed that in the videos for Javascript Training For EFS that some of the pre-written code (containing bugs that neophytes like myself are to practise debugging) were not contained in the software files that I have.

                    Are they located on this website? If so, I will download them and go to work, if not, I will transcribe them from the screen and then perform the work as instructed.

                    Thank you for your help and your patience with me.

                    dbuffalo
                    buffalotrader100

                    Comment


                    • #11
                      Hello dbuffalo,

                      If they are not in the .zip file included on the page for the JavaScript videos, then we do not have them. Here's the download link for the example files, if you haven't already downloaded.

                      JavaScript_Examples.zip
                      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


                      • #12
                        JasonK:

                        Thanks. I must have made a mistake when I went to the other link with the videos. I will get to work on these immediately (as I am now about halfway through the videos).

                        Happy Holidays,

                        dbuffalo
                        buffalotrader100

                        Comment

                        Working...
                        X