Announcement

Collapse
No announcement yet.

Average net change from Close to Close

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

  • Average net change from Close to Close

    Hi,

    I do not know how to write this Formula to help me get the average number of net change of the close for the last 5 days,
    from today close to previous day close, back to 5 days only, I want to get the number change no minus or plus sign please.

    Any help would be greatly appreciated.

    Thank you,
    Safa

  • #2
    use this function...

    here is a function you can add to your code to calculate the close to close range you are seeking..

    PHP Code:

    function fClosetoCloseRange(StartBarLength) {
    var 
    x;
    var 
    RangeTotal 0;
      for (
    x=StartBar;x<(StartBar-Length);x--) {
        
    RangeTotal += Math.abs(close(x)-close(x-1));
      }
     return (
    RangeTotal/Length);

    the way you would use this is...

    myrange = fClosetoCloseRange(-1, 5);

    This would calculate the average close to close range starting at bar -1 and going back 5 bars. the value would be placed in myrange (a variable).

    B
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      oops..

      an error in my code... use this one..

      PHP Code:
      function fClosetoCloseRange(StartBarLength) {
      var 
      x;
      var 
      RangeTotal 0;
        for (
      x=StartBar;x>(StartBar-Length);x--) {
          
      RangeTotal += Math.abs(close(x)-close(x-1));
        }
       return (
      RangeTotal/Length);

      B
      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        Thank you Brad for your respond

        Comment

        Working...
        X