Announcement

Collapse
No announcement yet.

displacing an efs?

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

  • displacing an efs?

    How would I go about modifying/adding code to displace an indicator forward by one or more bars? For example, below is part of the code for the Keltner channel efs. What changes would be required?

    function main(nInputLength, nConst) {
    if(nInputLength == null)
    nInputLength = 20;
    if(nInputLength <= 0)
    nInputLength = 20;

    var Factor = 2.5;
    if (nConst != null) Factor = nConst;

    var vHigh = getValue("High", 0, -nInputLength);
    var vLow = getValue("Low", 0, -nInputLength);
    var vClose = getValue("Close", 0, -nInputLength);
    if(vHigh == null || vLow == null || vClose == null)
    return;

    var vHLC3 = 0;
    var vHminL = 0;
    var i;

    for(i = 0; i < nInputLength; i++) {
    vHLC3 += (vHigh[i] + vLow[i] + vClose[i]) / 3;
    vHminL += vHigh[i] - vLow[i];
    }

    vHLC3 /= nInputLength;
    vHminL /= nInputLength;
    vHminL *= Factor;


    return new Array(vHLC3 + vHminL, vHLC3, vHLC3 - vHminL);
    }

  • #2
    Re: Reply to post 'displacing an efs?'

    The answer is probably a little tricker than just looking at that piece of
    code - can you attach the whole file?

    ----- Original Message -----
    From: <[email protected]>
    To: <[email protected]>
    Sent: Wednesday, January 21, 2004 5:47 PM
    Subject: Reply to post 'displacing an efs?'


    > Hello dloomis,
    >
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    >

    Comment


    • #3
      yep. here is the whole file if it helps.
      Attached Files

      Comment


      • #4
        bigtee
        If you want to displace the plot replace the 0 in the lines below with the desired negative offset (ie -1, -2, etc)
        var vHigh = getValue("High", 0, -nInputLength);
        var vLow = getValue("Low", 0, -nInputLength);
        var vClose = getValue("Close", 0, -nInputLength);
        I think that should do it
        Alex

        Comment


        • #5
          Thanks Alex, that does the trick nicely. Using a -3 dispaces forward by 3 bars.

          Comment

          Working...
          X