Announcement

Collapse
No announcement yet.

EFS Performance Help

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

  • EFS Performance Help

    I've been running a few EFS on 25 individual charts for some time, and on earlier builds, they ran ok. Everyonce in awhile they system would freeze on the open, but usually "catchup" after a minute or two. Lately, the system stays locked for a a few minutes on the open, and somedays requires a task manager to kill it. It is probably worse given the stocks I am watching....how much volume they are doing, etc. I know it is the EFS that are causing the system to perform as it is on the open, because without any EFS on the charts, it never misses a beat.

    The system: Dual 3.2ghz Xeons with HT, 1gb or Ram, 4 head Matrox and Dual Head Nvidia display adapters.

    I'll attach a screen shot of the Performance monitor screen capture.

    The EFS that seems to be causing the problems:

    NearHigh_Low.efs:
    ***********************************
    vLastAlert=-1;

    function preMain(){
    setPriceStudy(true);
    setStudyTitle("NearHigh_low");
    }

    function main(){

    var nearhigh = callFunction("/OHLC/gettodayohlc1.efs","main","High");
    var nearlow = callFunction ("/OHLC/gettodayohlc1.efs","main","Low");

    if (close() >=nearhigh -.10){
    onAction1();
    }
    else if (close() <=nearlow +.10){
    onAction2();
    }
    else{
    setChartBG(Color.lightgrey);
    }
    return null;
    }

    function onAction1(){
    setChartBG(Color.RGB(169,233,150));
    vLastAlert = 1;
    }
    function onAction2(){
    setChartBG(Color.RGB(254,188,200));
    vLastAlert = 2;
    }



    //function onAction2(){
    //setChartBG(Color.red);
    //vLastAlert = 2;
    //

    //function onAction3(){
    //setChartBG(Color.yellow);
    //vLastAlert = 3;
    //}



    And:
    gettodayohlc1.efs:

    /************************************************** **************************************************
    Copyright © eSignal, a division of Interactive Data Corporation. 2002. All rights reserved.
    This sample eSignal Formula Script (EFS) may be modified and saved under a new
    filename; however, eSignal is no longer responsible for the functionality once modified.
    eSignal reserves the right to modify and overwrite this EFS file with each new release.
    ************************************************** ************************************************** */
    function preMain() {
    }

    /** This formula was created to allow for back to back callFuntion() calls from an
    external formula.

    i.e.
    HH = callFunction("/OHLC/getTodayOHLC1.efs","main","High");
    LL = callFunction("/OHLC/getTodayOHLC1.efs","main","Low");
    **/


    var vSymbol;
    var vInterval;

    function main(sBarItem) {
    if(sBarItem == null) {
    return;
    }

    var vBar;
    var vBarTime;
    var vAbsTime;
    var vIndex;


    var nState = getBarState();
    vSymbol = getSymbol();
    vInterval = getInterval();
    vSymbol += ",D";

    if(vInterval == null)
    return;

    if(vInterval == "D" || vInterval == "W" || vInterval == "M")
    return;

    vBarTime = getValue("time");
    if(vBarTime != null) {
    vIndex = getFirstBarIndexOfDay(vBarTime, vSymbol);
    if (vIndex == null) vIndex = 0;
    if (vIndex != null) {
    vBar = getValueAbsolute(sBarItem, vIndex, vSymbol);
    return vBar;
    }
    }
    return;

    **************************************************





    Any assistance with improving the performance of these would be greatly appreciated. I searched for EFS perfomance, but wasnt' sure if what I found was similar.

    Thank you,

    cas


    edit: Note that my CPU usage never goes higher than 40%, even when esignal is frozen at the open, and everything else on the system works fine...so it is just esignal that is freezing.
    Attached Files
    Last edited by CAS1; 12-13-2004, 11:16 PM.

  • #2
    Hi cas,

    Try making the following changes to NearHigh_Low.efs. What I did is to reduce the number of times gettodayohlc1.efs was called to once every new bar versus every tick.

    I have not run this efs to see if it works, but it should.

    Looking at your performance monitor image, this modification should help, as the call to the gettodayohlc1.efs seems to be really taking significant resources. Please provide some feedback as to the effectiveness. Depending on how this works out, we could try something different to improve efs performance.



    PHP Code:
    NearHigh_Low.efs:
    ***********************************
    vLastAlert=-1;

    function 
    preMain(){
    setPriceStudy(true);
    setStudyTitle("NearHigh_low");
    }

    var 
    nearhigh 0;
    var 
    nearlow 0;
    function 
    main(){
    if (
    getBarState() == BARSTATE_NEWBAR){
    nearhigh callFunction("/OHLC/gettodayohlc1.efs","main","High"); 
    nearlow callFunction ("/OHLC/gettodayohlc1.efs","main","Low");
    }

    if (
    close() >=nearhigh -.10){
    onAction1();
    }
    else if (
    close() <=nearlow +.10){
    onAction2();
    }
    else{
    setChartBG(Color.lightgrey);
    }
    return 
    null;
    }

    function 
    onAction1(){
    setChartBG(Color.RGB(169,233,150));
    vLastAlert 1;
    }
    function 
    onAction2(){
    setChartBG(Color.RGB(254,188,200));
    vLastAlert 2;

    Comment


    • #3
      Steve,

      Thank you very much for looking at this. If I remember when this EFS was created (help from the forums) that was something that we discussed......when to have it update. So if I am understanding this correctly, if I am running a 3min bar, it will only update every 3 mins? I need to have it update every few seconds, because what I use this for is a visual signal that a stock is near the high/low, which can happen pretty fast. My system can handle this for all but the first few minutes of trading...otherwise the way it worked before was ok, but it sure would be nice to not have to task manager the thing every morning. :-)

      Thanks for any sugguestions/help!

      cas

      Comment


      • #4
        Hi cas,
        So if I am understanding this correctly, if I am running a 3min bar, it will only update every 3 mins?
        No, it still updates every tick, it just does not go and get todays OHLC value but every 3 min (something you really need only once per day).

        if (getBarState() == BARSTATE_NEWBAR){
        nearhigh = callFunction("/OHLC/gettodayohlc1.efs","main","High");
        nearlow = callFunction ("/OHLC/gettodayohlc1.efs","main","Low");
        }

        In your perfrormance monitor window snapshot, these calls were made (as a set) 183,995 times. Based on a 3 minute bar, these calls will now be made only 200 times (roughly) per advanced chart, per day.

        We could make it such that the OHLC value is called but once per advanced chart (per day), which is all that is really necessary, but I figured that a reduction of ~183,795 unecessary calls per day may help

        edit - ok, after looking at it, the call th the OHLC value must happen more than once per day, and I have a method you may find acceptable to make reading it only periodically more palatable. I'll make another post after lunchtime

        Last edited by Guest; 12-14-2004, 11:02 AM.

        Comment


        • #5
          Since the called EFS uses getValue("time") it isn't surprising that this can cause performance related problems.

          As has been discusses before on these forums, using getValue("time") can cause long delays due the resources needed to create a JS date object. Why this is, I'm not sure...there is some clear inefficiency in the coding, but this is a generic JS issue and not something specific to eSignal or EFS.

          Since Steve's fix will not work for you, the alternate "fix" is to use "rawtime" or better yet one of the routines that use rawtime. Note that while this fix does make things better, there is still latency associated with these calls and you can still see some delays if you use these calls to much.


          If I was at home I would make the changes and test, but I'm currently at a client site and unable to do so.

          G
          Garth

          Comment


          • #6
            Hi cas,

            Garth has a good point, accessing the other efs is really what is taking all the execution time. You can see it in the performance monitor.

            I looked at the suggested changes I made, and personally I think they will work well for you. Basically, using your 3 minute bar timeframe, the conditionals will be satisfied if they are within the OHLC value as determined within the last 3 minutes.

            If that is not good enough, here are two things as I see it which will both help.

            1) We can see if accessing time in a different way will work. As Garth indicated, Note that while this fix does make things better, there is still latency associated with these calls and you can still see some delays if you use these calls too much.

            -and/or-

            2) I revised the efs again. It gets the OHLC once upon startup. Then if the close(0) exceeds the high, the gettodayohlc1.efs is called. If the close(0) is below the low, the gettodayohlc1.efs is called. This reduces the number of calls significantly (at least 50%) since you will only be calling the gettodayohlc1.efs when the close(0) exceeds the respective high or low for the day.

            here is the re-revised efs:

            PHP Code:
            NearHigh_Low.efs:
            ***********************************
            vLastAlert=-1;

            function 
            preMain(){
            setPriceStudy(true);
            setStudyTitle("NearHigh_low");
            }

            var 
            nearhigh 0;
            var 
            nearlow 0;
            function 
            main(){
            if (
            getBarState() == BARSTATE_ALLBARS){
            nearhigh callFunction("/OHLC/gettodayohlc1.efs","main","High"); 
            nearlow callFunction ("/OHLC/gettodayohlc1.efs","main","Low");
            }

            if (
            close(0) >=nearhigh -.10){
            onAction1();
            if (
            close(0) > nearhigh)
            nearhigh callFunction("/OHLC/gettodayohlc1.efs","main","High"); 
            }
            else if (
            close(0) <=nearlow +.10){
            onAction2();
            if (
            close(0) < nearlow)
            nearlow callFunction ("/OHLC/gettodayohlc1.efs","main","Low");
            }
            else{
            setChartBG(Color.lightgrey);
            }
            return 
            null;
            }

            function 
            onAction1(){
            setChartBG(Color.RGB(169,233,150));
            vLastAlert 1;
            }
            function 
            onAction2(){
            setChartBG(Color.RGB(254,188,200));
            vLastAlert 2;

            Comment


            • #7
              Garth/Steve,

              First, thank you for the assistance. Next time you are in Vegas, I'll buy you a drink.

              Steve, I'll try your revised EFS. That seems to make sense that it will work. The problem I run into with a 3 min bar is that I need to see as new intra-day highs occur, so waiting for the bar to complete before it is called would not work. I'll run this EFS in the morning and see how it goes, and report back.

              Thanks again,

              cas

              Comment


              • #8
                If you want to know if the current price is nearing the high for the day, keep track of the high of the day on every tick. This will keep track of the high/low of the day

                if(close>hi2day)hi2day=close()
                if(close<lo2day)lo2day=close()

                This doesnt have significant over head, imho

                Dont for get to initialize hi2day and lo2day as 0 and 9999 respectively at the beginning of each day

                Just an idea to consider.

                Comment


                • #9
                  cas,

                  You are very welcome.

                  My hat is off to Dave, because he has an excellent idea. Please try this efs which incorporates his idea.

                  I am looking forward to hear if these help.

                  PHP Code:
                  NearHigh_Low.efs:
                  ***********************************
                  vLastAlert=-1;

                  function 
                  preMain(){
                  setPriceStudy(true);
                  setStudyTitle("NearHigh_low");
                  }

                  var 
                  nearhigh 0;
                  var 
                  nearlow 0;
                  function 
                  main(){
                  if (
                  getBarState() == BARSTATE_NEWBAR){
                  nearhigh callFunction("/OHLC/gettodayohlc1.efs","main","High"); 
                  nearlow callFunction ("/OHLC/gettodayohlc1.efs","main","Low");
                  }

                  if (
                  close(0) >=nearhigh -.10){
                  onAction1();
                  if(
                  close(0)>nearhigh)nearhigh=close(0);
                  }
                  else if (
                  close(0) <=nearlow +.10){
                  onAction2();
                  if (
                  close(0) < nearlow)nearlow=close(0);
                  }
                  else{
                  setChartBG(Color.lightgrey);
                  }
                  return 
                  null;
                  }

                  function 
                  onAction1(){
                  setChartBG(Color.RGB(169,233,150));
                  vLastAlert 1;
                  }
                  function 
                  onAction2(){
                  setChartBG(Color.RGB(254,188,200));
                  vLastAlert 2;

                  Comment


                  • #10
                    Dave, thank you for the idea, and thank you Steve for coding it. I'll run it in the morning and post the Performance monitor.


                    cas

                    Comment


                    • #11
                      cas - steve

                      You will need to initialize nearlo to something higher than the expected close, like 9999, or else close will never be less than nearlo, unless it goes negative, which hasn't happened lately


                      var nearlow = 999990;

                      if (close(0) <=nearlow +.10){

                      Comment


                      • #12
                        Well, system froze for about 30secs on the open, which is much better than before. It caught up and was fine after that initial freeze. From the perfomance monitor, the changes made an pretty good improvement. I'll keep watching to see how it goes.

                        thanks,

                        cas
                        Attached Files

                        Comment


                        • #13
                          Steve,

                          Green = High of day, which moves as the high goes higher (if it does), red = low for the day, same thing.

                          Thank you,

                          cas
                          Attached Files

                          Comment


                          • #14
                            Hi cas,

                            I have recoded our original effort, then added the high and low linesI believe it ready to try out. I put all the colors, line styles and other program variables such that they can be modified using the edit studies feature (accessable with a right click). Let me know it this works out. It is much faster than the original, as in addition to incorporating what we had done already, I incorporated all the required code into one efs.
                            Attached Files

                            Comment


                            • #15
                              Steve,

                              Thank you very much, this works great. No freezing on the open any more. Not only does it incorporate the performance increases, it makes the high/low lines easier to use as well. Thank you very much for taking the time and contributing to the community.

                              cas

                              Comment

                              Working...
                              X