I was putting together a function tonight and realized that it may demonstrate concepts to other efs users. The efs involves a number of relatively easy, and some not so easy concepts. The first copy attached to this post is a working efs laced with trace steps (a debug utility I put together) which record the output of various steps (with associated step number) to a file. In this case, the file will be written to the formula output directory (unless modified from the default, it will be C:\Program Files\eSignal\FormulaOutput) and is named Trace find hi.txt. The output file contains the variable values throughout execution of the efs.
The code populates an array in the getBarState() == BARSTATE_ALLBARS section which is true once during initial load of the efs. It then calls a function called find_hi which processes the array to find the high values of the array. Here is where it differs slightly from other pivot code (and is why I wrote it). If there are multiple highs, it identifies them, calculates the average bar value, and returns the average bar and the high.
After you run the efs, the file it writes can be opened up and the variable values can be seen throughout the execution of the code. One and 2 dimension arrays are used, data is passed to a function, if statements, while loops and other manipulations are performed. An interesting phenomina regarding the use of variables and populating arrays can be seen by commenting out line 79.
Each time the efs is run, the file is overwritten, so I would encourage the modification of the array values in lines 24 to 31, and re-running the efs to see how execution order is changed. If desired change other lines to see what changes (and don't forget line 79).
I will make another post after this one. This will include the same efs without all the trace statements. That will be much more readable and probably should be used when reviewing the steps of the efs versus the file output.
For those of you wondering, putting all these trace statements in my code is how I normally develope code which has so many twists and turns in it (and does not work right the first time). I take them out when I have verified it functions correctly.
The code populates an array in the getBarState() == BARSTATE_ALLBARS section which is true once during initial load of the efs. It then calls a function called find_hi which processes the array to find the high values of the array. Here is where it differs slightly from other pivot code (and is why I wrote it). If there are multiple highs, it identifies them, calculates the average bar value, and returns the average bar and the high.
After you run the efs, the file it writes can be opened up and the variable values can be seen throughout the execution of the code. One and 2 dimension arrays are used, data is passed to a function, if statements, while loops and other manipulations are performed. An interesting phenomina regarding the use of variables and populating arrays can be seen by commenting out line 79.
Each time the efs is run, the file is overwritten, so I would encourage the modification of the array values in lines 24 to 31, and re-running the efs to see how execution order is changed. If desired change other lines to see what changes (and don't forget line 79).
I will make another post after this one. This will include the same efs without all the trace statements. That will be much more readable and probably should be used when reviewing the steps of the efs versus the file output.
For those of you wondering, putting all these trace statements in my code is how I normally develope code which has so many twists and turns in it (and does not work right the first time). I take them out when I have verified it functions correctly.
Comment