Announcement

Collapse
No announcement yet.

efsExternal and $PLAYBACK

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

  • efsExternal and $PLAYBACK

    I have been using efsExternal features successfully for a while now and quite like the result.

    However, there seem to be quite a few restrictions. I have searched the Knowledgebase and Forums for a document on the subject, but was unable to find.

    So, I have listed below my observations. Please let me know if I am incorrect or if there are any others I need to know about.

    1. In Playback mode, the following message appears in the Formula Output window: "Symbol $P cannot be processed by this program". There is no evidence of the efsExternal code having been executed even though it works fine in real time (including during bar loading). I assume that efsExternal therefore does not work in Playback mode.

    2. Plot is suppressed. Plot lines in the "called" program no longer appear on the chart. This I expected. However, I found that text does not appear either. Can I therefore assume that line functions and buttons are also supressed?

    3. setComputeOnClose(); Overwritten. The main indicator I have developed calculates every Tick. I had another indicator I wanted to call and use the result. The "called" indicator was set to compute on bar close. This mode seems to have been overwritten and, since the code was not designed for tick-by-tick calculation, I was unable to use it without significant modification.

    4. Plot Colors. If the color of a line normally plotted by the "called" program is of significance, there is no way for the "calling" program to know this (expected, but worth mentioning for others reading this). It is therefore necessary to modify the "called" code to include a parameter that distinguishes its execution mode ("native" or "called"), and to return an additional value representing the color as an indicator when in "called" mode.

    Hope this is helpful.

    Others please feel free to add observations as I am sure they will be a great help in the future.

    Thank you.

  • #2
    Hi griesha30246,

    This is a nice synopsis of behaviors associated with the use of efsExternal(). I have not used this functionality as extensively as you have, and was not aware of some of these issues, so what you have compiled is good information. I have a few questions and comments for your consideration.

    1. Have you tried sending the efs called by efsExternal getSymbol() as the symbol? I thought this was the only way to make it work. Another function that may be of some help is isPlayBackMode() where you can use as a conditional test either in the efs calling or the efs being called (not sure about the latter).

    3. I have used a method to adapt functions that are called by efsInternal to run like they were setup with setComputeOnClose() and was wondering if you had tried this with efsExternal. Specifically, you define the variables that you will be returning as global variables. Then you enclose the meat of the efs with if (getBarState() == BARSTATE_NEWBAR) { inside here } and set those global variables within this section. Then finally, the return statement is outside the if (getBarState() == BARSTATE_NEWBAR) { } section. Since it returns only the previously defined global variables, you still get variables returned every tick from the last time a new bar came in. Now having said that, I am not sure as to the implications of whether you would have to refer to the previous bar or not, i.e. close(-1) versus close(0).

    Finally, a new function was added with EFS2. The function is isComputeOnClose(). I thought this may be useful as well within the called efs.

    Anyways, these were some things I thought I would add to what you had put together. As with you, I am interested in any feedback as well.

    Thanks,

    Comment


    • #3
      Hello griesha30246,

      1. efsExternal() can work in tick playback mode. It's difficult to say what is causing the error you are seeing. Please post your formula or a code example that reproduces the error and I'll take a look.

      2. Calling another study through efsExternal() does not load the study into the chart. It simply allows the calling EFS to use the return values from the called EFS. If you want those value to be plotted on the chart you then have to return them from your calling EFS. Any drawing functions (text, lines, shapes and images) in the called EFS will not appear on the chart. Only the drawing functions that reside in your calling EFS will take affect on the chart. efsExternal() is a function that is only used to create a series from the returned values of an external EFS.

      3. The preMain() settings in a called EFS through efsExternal() will not be used by your calling EFS. The calling EFS will operate under its own preMain() settings. You will not be able to use a called EFS under compute on close when the calling EFS is processing tick-by-tick.

      4. See #2. You have the incorrect expectation as to what efsExternal() is supposed to do. When using this function, remember that it only creates a series out of the returned values from the called EFS. It does not run the EFS as if it were applied to your chart independently.
      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


      • #4
        Thank you for the replies Jason & Steve.

        Knowing that Playback is supposed to work was very useful information. On that basis, I investigated far more deeply.

        Eventually I found that I was missing a (minor) parameter (#15 of 17) to the study called by efsExternal. This meant that the next 2 parameters (the function type - "normal" or "called" and Playback Symbol - "AB") were invalid which, in turn, meant that my Error Routine displayed as Text Relative rather than Debug Print, hence masking the nature of the problem (which would not occur during real-time operation).

        So, another "learning experience".

        I must admit I had hope-ations rather than expect-ations of efsExternal. These were based on my background in business systems development, where it's normal practice to split off commonly-used sub functions into seperate code segments - without the non-display restrictions. Still, efsExternal is very useful and knowing the restrictions is valuable help in further design work. Thanks again.

        Just one other question, if I may.....

        Is the reading/writing of files also restricted within a "called" study and, is this also the case in Playback mode. Thx.

        G.

        Comment


        • #5
          Hello griesha30246,

          Reading and writing to a file will execute through a formula called by efsExternal. Works in tick playback as well. It's not a very efficient process however. What exactly are you trying to accomplish? Perhaps there is a better alternative. Please describe what you are trying to achieve.
          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


          • #6
            File I/O Requirements

            I have already used file I/O in Playback to simulate RT mode to test studies relying on getMostRecentBid() and getMostRecentBidSize(). (I do this by manually reading a copy of the Playback file) It's a pain synchronising it to actual Playback prices, but works fine (as long as eSig auto sync doesn't kick in, that is).

            I have also found that (with the complexity of some of my studies) I need a table of defaults for each (futures) symbol. These include: tick size (used for rounding and projection of entry/exit price); average daily volume, approx time equiv of 500 tick bar, avg vol per tick, $ val per tick..........

            Since a number of studies I have developed need the same information, I thought creating the file in (say) MS Excel and inputting it via a standardised study (efsExternal call) would be the best way to deliver consistent parameters to all effected studies. Naturally, file would only be interrogated at study start-up.

            Now that I have an understanding of file I/O, I plan to develop some complex price/volume/timing analyses. The intention is to produce a set of pivots, stall points, price preferences, etc.. that will plot as lines (with meaningful colors, thicknesses and annotations) AND the values will also be accessible to non-price studies for Alerts, etc. The analyses would be based on previous days' action and would not run real-time.

            At present, I am looking at Excel/VB for the analysis part (using downloaded Tick file). This would create a text-format output containing appropriate price levels, strengths, timings, etc. I had previously planned to create a study as a "sub function" (to execute using efsExternal) to read the file, save the values pertaining to the current symbol and plot the lines. The latter I will have to re-think.

            I am not planning to have file I/O running in real-time, though I may elect to produce some "log type" of output in certain situations on (say) a 30' basis.

            I have looked a little at Global Variables. They may have some part to play, but they seem best suited to fixed values rather than anything dynamic (esp. during bar loading).

            Hope this helps a little in understanding my thinking.

            Any additional ideas/questions, most welcomed.

            G.

            Comment


            • #7
              Hello G,

              Thanks for the detailed reply. Sounds like you have some very interesting ideas. I have a few suggestions for you to explore that may be helpful to your project.

              I have already used file I/O in Playback to simulate RT mode to test studies relying on getMostRecentBid() and getMostRecentBidSize(). (I do this by manually reading a copy of the Playback file) It's a pain synchronising it to actual Playback prices, but works fine (as long as eSig auto sync doesn't kick in, that is).
              If you don't want EFS2 to do any synching then you shouldn't use efsExternal(). It doesn't sound like you need the result to be returned as a series anyway. As an alternative, you could try call() or callFunction(). Or better yet, this routine could be handled by custom functions that you create in a Function Library file. This would allow you to store all your custom File I/O operations in a single file that could be used by multiple formulas.

              I have also found that (with the complexity of some of my studies) I need a table of defaults for each (futures) symbol. These include: tick size (used for rounding and projection of entry/exit price); average daily volume, approx time equiv of 500 tick bar, avg vol per tick, $ val per tick..........

              Since a number of studies I have developed need the same information, I thought creating the file in (say) MS Excel and inputting it via a standardised study (efsExternal call) would be the best way to deliver consistent parameters to all effected studies. Naturally, file would only be interrogated at study start-up.

              Now that I have an understanding of file I/O, I plan to develop some complex price/volume/timing analyses. The intention is to produce a set of pivots, stall points, price preferences, etc.. that will plot as lines (with meaningful colors, thicknesses and annotations) AND the values will also be accessible to non-price studies for Alerts, etc. The analyses would be based on previous days' action and would not run real-time.

              At present, I am looking at Excel/VB for the analysis part (using downloaded Tick file). This would create a text-format output containing appropriate price levels, strengths, timings, etc. I had previously planned to create a study as a "sub function" (to execute using efsExternal) to read the file, save the values pertaining to the current symbol and plot the lines. The latter I will have to re-think.

              I am not planning to have file I/O running in real-time, though I may elect to produce some "log type" of output in certain situations on (say) a 30' basis.

              I have looked a little at Global Variables. They may have some part to play, but they seem best suited to fixed values rather than anything dynamic (esp. during bar loading).
              Again, I don't think efsExternal() is what you need here (for the constant values) as you don't need these defaults to be in the form of a series. Your formula should have some global variables declared that will store those defaults. If the variable needs to be dynamic, it does not necessarily have to be a global variable, but you could still utilize the Function Library calls inside an efsInternal() function to create it as a series. To populate the global constants, you only need to do this once when the study is initializing. Check for the bar state of BARSTATE_ALLBARS using getBarState() or create a global flag that will allow the event to occur only once at the beginning of the initialization process. Since some of the defaults are dependant on the symbol, you could pass the symbol as a parameter to your Function Library functions, which it would use to grab the data you're storing in the text files. For any values that need to be calculated you could have those operations performed in a function library as well instead of Excel. Such as the average daily volume calc etc. Only use efsExternal() or efsInternal() for the data that you need to have in the form of a series. Hope this helps.
              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
                Series vs Multiple Values

                Thanks for all the suggestions. I've been trying to digest how these might affect my development work so far...

                I am already using a single "common function" (efsExternal call) in 2 different studies (with different input parameter values) and plotting them on the same chart (as different sub-graphs) - with no real problem. So I am not sure how utilising library functions would provide any additional benefit.

                However, the response did prompt me to consider my understanding of what efsExternal returns to the "calling" program.

                I input 17 parameters (including the symbol for playback) and need to get back 8 different results each time. I do this using the getSeries() construct in the calling program.

                So I am wondering if there is a simpler/more efficient way to return multiple values to the calling program?

                Thanks again.

                Comment


                • #9
                  Hello G,

                  efsExternal() returns a series to the calling study. This series will be synchronized with your main chart. In your case the call is return 8 series.

                  At this point it would be beneficial to see some code examples of your process in order to provide more specific suggestions.
                  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


                  • #10
                    Storing a large number of constants

                    Hi Jason. Like griesha30246, while running a tick file in Playback I would like to be able to call a previously stored value associated with each tick. You suggested to G storing those values in the Function Library. Considering there would be over 150,000 values what would be the most efficient means of storing them in and calling them from the Function Library? Up to this point I have used assigned variables and small arrays to store constants because I have been dealing with a relatively small number of values. Thanks for any suggestions.

                    Mike

                    Comment


                    • #11
                      Storing a large number of constants

                      A follow-up question: In your 9-14-2005 post in this thread you wrote, “…your Function Library function …would … grab the data you're storing in the text files.” How exactly does that work? If you’re suggesting using “readln()” I’ve never been able to get that command to read beyond the first line of any text file. Obviously I’m missing something in its implementation. Could you explain, specifically, how it could be used in this situation (if indeed that is what you’re suggesting) and/or refer me to an example efs that uses it to read a large number of stored values and assign them consecutively to one variable or concurrently to a large number of them. Thanks again.

                      Mike

                      Comment


                      • #12
                        Hello Mike,

                        That's correct, you would use the .readln() method of the File Object to read data line-by-line into your formula. At the link provided there is a very basic example of how to do this. The line variable would contain the data for each line as the EFS code loops through the text file's data. On each iteration of the loop you could then pass that variable to an array or do what ever you need. Here's another basic example that shows how you can store the data to an array.

                        Save the attached file, TestData.txt to your eSignal\FormulaOutput\ folder.

                        Then run the following code example.

                        PHP Code:
                        function preMain() {    
                            
                        setPriceStudy(true);

                        }

                        var 
                        bInit false;
                        var 
                        myArray = new Array();

                        function 
                        main() { 

                            if (
                        bInit == false) {
                                
                        //read a file 
                                
                        var = new File"TestData.txt" ); 
                                if( 
                        f.exists() ) {  
                                    
                        f.open"rt" ); 
                                    var 
                        0;
                                    while( !
                        f.eof() ) {  
                                        
                        myArray[i] = f.readln();  
                                        
                        debugPrintln"Line " +": " myArray[i] );  
                                        
                        i++;
                                    }  
                                    
                        f.close();  
                                }
                                
                        bInit true;
                            }
                            
                            return;

                        You should see the following in the Formula Output window.



                        The global variable, myArray, now contains the data from the text file. This routine can be performed in either a function library or EFS file depending on your specific needs. Hope this helps.
                        Attached Files
                        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


                        • #13
                          Thanks Jason. Your post does help. I've seen the FILE OBJECT documentation and its reference to readln() before but it doesn't include the incremental loop you included in your example. So I can see now why my previous attempts at using readln() resulted in reading only the first data entry in a txt file. Thanks again. Happy Holidays.

                          Mike

                          Comment


                          • #14
                            You're most welcome and Happy Holidays to you as well.
                            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