Announcement

Collapse
No announcement yet.

Alternate EFS's

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

  • Alternate EFS's

    Edit - As of April 2005, eSignal has provided a utility function that accomplishes this function called getCurrentBarCount(); Thanks!

    One of the things that has always driven me nuts is that when I am going back over data, armed only with barcount, that I cannot get the barcount to actively display in the cursor window (for the intermediate values).

    Now I could have done it before by just incrementing a counter (barcount++ ) within the efs, however I never really thought about it before now. Well, I was playing with creating an object class definition for barcount, and I came up with this efs.

    It not only keeps an accurate barcount with all variants of tick charts, as an added bonus, it displays an active barcount in the cursor window.

    PHP Code:
    /***********************************************
    Steve Hare © October 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.                      

    Title:        barcount class.efs
    By:         Steve Hare
    Email:      [email][email protected][/email]
    Version:    initital release 10/18/2004

    ==============================================
    Fix History:

    ==============================================
    Description:   

    Displays barcount in cursor window, simple demo of establish a method within a object class definition

    Dislaimer: For educational purposes only! Obviously, no guarantees 
    whatsoever and use at your own risk.
    *************************************************/

    function preMain(){
        
    setPriceStudy(true);
        
    setShowTitleParameters(false);
        
    setStudyTitle("barcount Object Class");
        
    setShowCursorLabel(true);
        
    setCursorLabelName("BarCount"0);
        
    setDefaultBarFgColor(Color.red0);
        }
    function 
    main(){
        if (
    getBarState() == BARSTATE_ALLBARS) {//true once during initial load and subsequent reload
            
    barcount = new barcount_variable_class();//barcount.num()
        
    }
        return 
    ""+barcount.num();
    }
    function 
    postMain() {
    }

    var 
    barcount;
    function 
    barcount_variable_class(){
        
    this.num=function(){return(1+getCurrentBarIndex()-getOldestBarIndex());};//note - last semicolon required

    Here is a link to a copy in my fileshare area. http://share.esignal.com/ContentRoot...10+18+2004.efsEdit - As of April 2005, eSignal has provided a utility function that accomplishes this function called getCurrentBarCount(); Thanks Gentlemen!
    Attached Files
    Last edited by ; 05-21-2005, 10:23 AM.

  • #2
    Trend Line Alert EFS

    There have been several board members asking for an efs that would alarm when a user defined trend line was exceeded. I had been working on something similar, so I went ahead and coded an efs along those lines.

    PHP Code:
    /*********************************************************
    Provided By : Steve Hare © October 2004                          
    EFS Formula : Trend Line Alert                     

    Version 1.0
    10/24/2004

    Notes:
    * Price study
    * Provides both an audible and a visible alert when Trend Line is exceeded
    * Formula Parameters 
        - Deadband -    Default: 5        (number of bars to re-arm)
        - Location -    Default: 0        (corner of screen to accupy going clockwise)
        - Thickness -   Default: 2        (thickness of trend line)
        - Upper Color - Default: green    (color of Trend line if drawn above price)
        - Lower Color - Default: red      (color of Trend line if drawn below price)
        - AD Color -    Default: red      (color of Action Dot)
    * Instructions
       - Select two points on screen to draw trendline through by double clicking screen at those locations
         Action Dots will appear at those points
       - The Action Dots can be moved by simply double clicking another point on the screen
         The closest Action Dot will move to the new location
         If a trendline was drawn, it will be removed if an Action Dot is moved
       - Left click the Draw button and a Trend Line will be drawn
         If drawn above the current price, the line will alarm when price goes above the default green line
         If drawn below the current price, the line will alarm when price goes below the default red line
         If a line has been exceeded, pressing the Draw button will reactivate the trend line alarm based on the two previous rules
       - Right click the buttons to change their mode 
       - Locations 2 and 3 are on the right side of the screen, 5 bars to the right of the most recent bar 
         To see these button with these locations selected, you must left click and drag the price pane to the left
    ****************************************************************/ 
    Attached Files

    Comment


    • #3
      Usage Question Followup

      I received some questions on the use of the Trend Line Alarm efs in a PM that is worthwhile to share IMO as follows.
      Thanks! ... What would you say are the main differences between this new EFS and the old one that we had been using?
      You are welcome.

      ...one major difference is that the efs will leave visual clues as to where you double click, what I call Action Dots. If you have two dots on the screen and you click the draw button, that is where the line goes.

      Another major difference is the presence of the buttons and the options that they afford you. When you right click the draw button, it will become the clear line button. That allows you to clear the screen of action dots and lines if you left click it. Another right button click returns it to the draw button once more. The other is the magnet button. You can easily turn off the magnet, then you can draw a line that is not anchored to price (that button you click with the right mouse button only, as it is only a toggle) If the button indicates the magnet is on, the action dot will go to the closest open, high, low or close to where you clicked, otherwise, if the magnet is off, the action dot is placed at the location where you double clicked the chart.

      Everything else is pretty much written down on the instructions for use.


      Also, am I to double-click (two clicks) once and the startpont of the trendline and again (two clicks) at the end of the trendline? Then click the 'draw' tool, right? Thanks.
      Regarding your question as to the first double click (action dot) and the second one, they may be anywhere you want them, in any order. There are no rules there. Once you have two action dots on the screen, click the 'draw' tool. If you double click somewhere on the screen again, the line will be cleared and you will move the closest action dot to the new location. Once again, to draw a new line, click the 'draw' tool.

      The line will extend from the action dot that is furthest back in history, through the most recent action dot, past the most recent (developing) bar by 10 bars (default). The alarm level will be based on the lines' value at the most recent bar.

      Play with it, you cannot break it (at least I do not think so ;-)
      Last edited by ; 10-27-2004, 07:45 PM.

      Comment


      • #4
        Great work as always, will have to test this out in a few weeks.

        Thanks Steve.
        Excellent book on JavaScript for beginners

        Comment


        • #5
          Dan,

          Thank you for the kind words. I think you will find it's behavior interesting. While similar in concept to some of our previous work, it is very different in that I am using class definitions with imbedded methods (functions).

          When you call different variables, they are actually implementing functions based upon the initial object definition. Specifically, in this case, you define the object initially when you draw the line, saving the two points in the chart as object variables which remain static for the life of the object (line). Subsequently, when a new bar comes in, I redraw the line using object variables, which when referenced in the draw statement, actually implement functions. These functions recalculate the beginning and end of the line segment using these static object variables and the newest barcount. The alarms are also imbedded in the original object and are referenced similarly.

          The advantage of this technique is that it could be easily expanded to contain, for example, 20 lines, each that would be updated every bar, each defined individually, with it's own alarm. Since each one would be an individual object that takes care of all of it's properties as an individual entity, you could keep track of them with a simple (relatively speaking) 1 dimensional array of the different objects.

          Take care,

          Comment


          • #6
            Steve....

            Great work.. I've used "arrays of objects" in many of my coding items. They are very handy for just such an EFS. They can be used for other things (Money management, multiple alerts, multiple conditions)...

            For example, one of the interesting things I've found is you can store your "conditions" as "text" and use eval() to test these conditions from the array.

            I could then set my condition variable to "((close() > open()) && (close(-1) > open(-1)))"

            then, as I loop thru my array, I could test this by using the eval() function..

            conditionarray[x].Valid = eval(conditionarray[x].Condition);

            Thought this would "spur" some more interesting EFSs from you. Great work though.

            B
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment


            • #7
              Extended EFS Function - Rounding for Fractional Futures Contracts

              Extended EFS Function - Rounding for Fractional Futures Contracts

              While working with a friend, he expressed the wish that there was an efs function to round efs output to the nearest fractional value associated with a given contract movement (e.g. a quarter point or 32nd point).

              While we cannot embed this functionality into the base code, we can, and did, create a small snippet of code that can be added to an efs that works just like an efs native function.

              Here it is:


              var Rnd = new round_efs_extension();//Rnd.Dn(number,tick amount);Rnd.Up(number,tick amount);Rnd.Nt(number,tick amount);
              function round_efs_extension(){
              this.Up = function(tmp1,div1){return Math.floor((tmp1+1/div1)*div1)/div1;}//Round Up
              this.Dn = function(tmp1,div1){return Math.ceil((tmp1-1/div1)*div1)/div1;}//Round Down
              this.Nt = function(tmp1,div1){return Math.round(tmp1*div1)/div1;}//Round Nearest
              }



              To use this Extended EFS Function in an efs, just copy the above code snippet to your efs and you can use the rounding functions associated with it

              for example, if your issue has a 1/4 point minimum tick movement

              You can round down to the nearest tick amount ==> Rnd.Dn(number,4);
              You can round up to the nearest tick amount ==> Rnd.Up(number,4);
              You can round to the nearest tick amount ==> Rnd.Nt(number,4);





              for example, if your issue has a 1/32 point minimum tick movement

              You can round down to the nearest tick amount ==> Rnd.Dn(number,32);
              You can round up to the nearest tick amount ==> Rnd.Up(number,32);
              You can round to the nearest tick amount ==> Rnd.Nt(number,32);




              for example, if your issue has a 1/10 point minimum tick movement

              You can round down to the nearest tick amount ==> Rnd.Dn(number,10);
              You can round up to the nearest tick amount ==> Rnd.Up(number,10);
              You can round to the nearest tick amount ==> Rnd.Nt(number,10);



              PHP Code:
              /**************************************************
              Steve Hare © 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.                      

              Title:  Rounding.efs
              By:         Steve Hare
              Email:      [email][email protected][/email]
              Version:    initial release 12/01/2004

              Description:   Creates an Extended EFS Function - Rounding for Fractional Futures Contracts
              efs function to round efs output to the nearest fractional value associated with a given 
              contract movement (e.g. a quarter point, 1/10th, 32nd point, etc).

              disclaimer: For educational purposes only! Obviously, no guarantees 
              whatsoever and use at your own risk.
              *************************************************/

              function preMain(){
                
              setPriceStudy(true);
               
              setShowTitleParameters(false);
               
              setStudyTitle("Rounding");
               
              setShowCursorLabel(true);
               
              setCursorLabelName("Up"0);
                
              setCursorLabelName("Down"1);
                
              setCursorLabelName("Nearest"2);
               
              setDefaultBarFgColor(Color.red0);
                
              setDefaultBarFgColor(Color.blue1);
                
              setDefaultBarFgColor(Color.green2);
               
              setDefaultBarThickness(2,0);
               
              setDefaultBarThickness(2,1);
               
              setDefaultBarThickness(2,2);
              }

              var 
              vMA null;

              function 
              main(){

              if (
              vMA == nullvMA = new MAStudy(100"Close"MAStudy.SIMPLE);

              var 
              vX vMA.getValue(MAStudy.MA);
              if(
              vX==null||vX==0) return;

              return 
              Rnd.Nt(vX,10);
              }

              //rounding function rounding function rounding function rounding function rounding function rounding function rounding function 
              var Rnd = new round_efs_extension();//Rnd.Dn(number,tick amount);Rnd.Up(number,tick amount);Rnd.Nt(number,tick amount);
              function round_efs_extension(){
               
              this.Up = function(tmp1,div1){return Math.floor((tmp1+1/div1)*div1)/div1;}//Round Up
               
              this.Dn = function(tmp1,div1){return Math.ceil((tmp1-1/div1)*div1)/div1;}//Round Down
               
              this.Nt = function(tmp1,div1){return Math.round(tmp1*div1)/div1;}//Round Nearest

              Here is a link to a copy in my fileshare area.

              http://share.esignal.com/ContentRoot...2+01+2004d.efs

              Comment


              • #8
                I had forgotten to add the file for downloading, as I found out, if you do not include a file in the original post, you cannot add one with the edit function, which is the case here...

                Therefore, have to add it with another post, here it is, hopefully this will prove useful
                Attached Files

                Comment


                • #9
                  Trend Line Alert for Small Charts

                  Steve,
                  Thank you very much for you tend line alert.efs. It works wonderfully on large charts.

                  I have many small charts so I took the liberty of modifying your trend line.efs to fit it into small charts. Most changes simply reduce the wording to minimize the space used by the efs. The only really change I made was to set the price magnet default to off.

                  I've add my comments at the end of your comment section and I've added a comment to each line that I change. I hope you like it.

                  Chip
                  Attached Files

                  Comment


                  • #10
                    Chip,

                    I like the way you marked it up, it makes it easy to see what changes you have made. I looked at the changes, and it looks like it will meet your objectives very well!

                    Two things to consider.

                    1) you can add or modify the alert methods in the excerpted functions below:

                    PHP Code:
                    function Hi_Alert_Actions(tmp){
                        
                    Alert.playSound("Ding.wav");
                        
                    Alert.addToList(getSymbol()+"  "+getInterval(),"Crossing Up, Trend Line Alert @ "+tmp.toFixed(3),Color.black,up_color);
                    }

                    function 
                    Lo_Alert_Actions(tmp){
                        
                    Alert.playSound("ding.wav");
                        
                    Alert.addToList(getSymbol()+"  "+getInterval(),"Crossing Down, Trend Line Alert @ "+tmp.toFixed(3),Color.black,down_color);

                    2) you can modify the location of the buttons on the efs to any of the corners of the chart through the edit studies window.

                    Good job on the modifications.

                    Comment


                    • #11
                      I have put together an EFS2 library entitled shUtilities which is a compilation of functions. At this time, it is comprised of time functions that return various time formats. I will be adding other utility functions periodically to the library.

                      The library is contained in my fileshare and can be downloaded and used by those utilizing eSignal version 7.9 build 708 or later. Once downloaded, the utilities will behave similar to the efs built in functions and can easily be inserted either manually, or by using the EFS2 Toolbox in the EFS editor. They can be used just like the efs and efs2 functions or other libraries such as amStudies.

                      I attached a version of the help file which describes the functions and their syntax, contains installation instructions and provides examples of how they could be used.
                      Attached Files

                      Comment


                      • #12
                        Trend Line Alert Utility

                        I modified the Trend Line Alerts efs I wrote last year. It now saves the trend lines to a file(s) such that when the efs is reloaded in a chart with the same symbol and interval, the alert line is reloaded and activated. Further, using some new EFS2 functionality, it allows the buttons to be moved around the chart by selecting the button option and doubleclicking the desired new location on the chart.

                        Here is a screenshot of a trend line on the chart with the trend line alarm <Active> ...






                        Now here is a screenshot with the trend line exceeded and the Alert Window activated...








                        Here is a screenshot that shows the new position of the buttons on the screen when I went through the location selector until the button cycled to the third pre-set location. When you exit the efs, the location of the buttons will be saved such that when the efs is restarted, they will return to that location. Should you have multiple copies of the efs loaded, the button location that is remembered will be the location of the buttons in the last trendlines efs saved...








                        This is a screenshot of with the 5th button preset option displayed. You can doubleclick anywhere on the chart and relocate the buttons to that location. Again, when you exit the efs, the location of the buttons will be saved such that when the efs is restarted, they will return to that location...









                        Instructions for how to use the efs are included in the beginning of the efs.

                        Here is a copy of the efs available for download ...
                        Attached Files

                        Comment


                        • #13
                          Very nice work Steve! Thanks for sharing this with the community!

                          Comment


                          • #14
                            Hi Duane,

                            Thank you, it was my pleasure.

                            Regards,

                            Comment


                            • #15
                              efs programming techniques

                              I was working on converting a binary number to a decimal value and back again. I was not planning on posting the efs, until I realized it had several efs programming techniques / concepts that some may find useful.

                              The Concepts are as follows:
                              • shows how to create a function that returns a value
                              • shows how to create a function that returns an array
                              • creates a simple array and shows how to reverse the elements
                              • shows how to get the length of an array and cycle through its elements
                              • uses the modulo method for remainders
                              • uses the Math.pow (er) exponential method
                              • uses the Math.floor rounding down method
                              • demonstrates the "for" loop
                              • demonstrates the "do...while" loop


                              Here is the output from the efs:


                              13: tmp() = 1,0,0,1,1,1,0,1,0,0,0,0,0,1,1,1
                              15: tmp() Array converted to Decimal = 40199
                              17: tmp() = 1,0,0,1,1,1,0,1,0,0,0,0,0,1,1,1 (Decimal value converted back to Digital )


                              Here is a link to my fileshare area which has a copy of the efs.

                              It also can be downloaded directly here:
                              Attached Files

                              Comment

                              Working...
                              X