Announcement

Collapse
No announcement yet.

Making Code more efficient

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

  • Making Code more efficient

    I created an efs that uses the Donchian higher and lower functions to indicate when a trend is changing. Roughly, if the current high is higher than the previous n bars high I paint a bar green and conversely for a bar low.

    These function take a fairly long time to load data.

    Does anyone know of a more efficient way to achieve what I am doing? For example is the highest() function better, or just creating an array of the past n high/lows and getting the max/min. What if I limit the amount of data through a time template?

    Thanks.

  • #2
    buhrmaster
    Without seeing how the study is implemented it is difficult to provide any suggestions.
    You may want to post a working sample of the script and also details as to how many bars you are loading, etc. and someone may be able to help
    Alex

    Comment


    • #3
      Alex-

      Thanks for the response.

      I found the problem -- I forgot to comment out the debug statements -- a little embarrassing.

      However I wonder if there is a speed difference between the old EFS built-in studies vs. the new EFS2 style studies? On some other charts I found that the EFS2 studies don't update on the chart as quickly so I had to roll back to the old EFS versions.

      Comment


      • #4
        buhrmaster
        It depends on how you are using the EFS2 study.
        If you use it in a way that is functionally equivalent to the EFS1 study ie you declare the study globally then initialize it once and return the value using the getValue() method then my experience is that the EFS2 studies are actually slightly more efficient. If instead you return the series then the EFS2 study is going to use more computational time but at that point it is also perfoming functions that are not available to the EFS1 version (ie it is enabled to maintain full synchronization between intervals)
        Alex

        Comment

        Working...
        X