Announcement

Collapse
No announcement yet.

Reducing CPU Load

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

  • Reducing CPU Load

    There was a prior thread addessing the removal of arrows applied to a chart to reduce the cpu load. I have searched and can not find it. Can someone point it out to me?

    Best Regards,

    Alan

  • #2
    the easiest way to handle this is to create a recycling graphics ID for each bar. This way you can clear older shapes/text/lines by re-assigning a new shape/text/line with the same TAG ID.

    First, you need a function to recycle the values (lets say 1 to 100).

    Then you need to track when new bars form on the chart so you can increment the counter.

    Then you need to use that counter in your "drawShape" function in the TAG or ID field.

    When the numbers recycle, it will clear the older shapes and replace it with the new ones... simple and easy on CPU loads.

    PHP Code:
    var vGraphicID 0;
    var 
    nLastRawTime null;
    var 
    BarCounter 0;  //  Counts the number of bars in the chart

    function main() {

    //  This is the function I use to finding new bars on the chart
       //  If new bar
       
    if ((getValue("rawtime"0) != nLastRawTime) ) {
         
    nLastRawTime getValue("rawtime"0);
         
    BarCounter += 1;

         
    //  Increment Graphics Counter.
         
    fIncrementGraphicID()
      }

           
    drawShapeRelative(0high(0)+MakeGOffset(),  Shape.DOWNARROW""Color.redShape.TOP Shape.ONTOP vGraphicID+"SE");


      return;
    }


    function 
    fIncrementGraphicID() {
      
    vGraphicID += 1;
      if (
    vGraphicID 100) { vGraphicID 1;  }
    }

    function 
    MakeGOffset() {
      return (
    high(-1)-low(-1))/3);

    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thank you for the reply. I will test this over the weekend.

      Best Regards,

      Alan

      Comment

      Working...
      X