Announcement

Collapse
No announcement yet.

How to calculate an ATR for a Spread?

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

  • How to calculate an ATR for a Spread?

    Can someone please show me a detailed calculation of how to come up with the daily ATR for a spread between two symbols for example the spread 3 * GE - UTX. The Esignal ATR as of today is 1.69 but I can not get that exact number.

    For daily ATR is Esignal only using end of day data?

    Notes:
    - I assume that the calc is based on the the spreads enod of day open, hi, low, close
    - ATR should be the average of max of (Previous Close - Low), (Previous Close - High), (High - Low) across a time period
    - I seem to be able to duplicate the calculation if the the spread is GE - UTX but when I use a ratio I can get close but not the same number
    - I have asked your reps before on this but they just give me a general answer - could you please send me a detailed calc

    Thanks!!!!

  • #2
    Under the EFS Editor, there's a formula for ATR under the Library folder. Here it is. Since this is EFS related, I'm going to move the post so better qualified people can chime in if needed. Thx.

    ---------------------------------------

    function preMain() {
    setStudyTitle("Average True Range");
    setCursorLabelName("ATR");

    var fp1 = new FunctionParameter("nInputPeriod", FunctionParameter.NUMBER);
    fp1.setName("Length");
    fp1.setLowerLimit(2); // the nInputPeriod can't less than 2
    fp1.setDefault(14);
    }

    var AryTTR = null;

    function main(nInputPeriod){
    var vState = getBarState();

    if (AryTTR == null) AryTTR = new Array(nInputPeriod);

    var dH = high(0);
    var dL = low(0);
    var dC = close(-1);

    var HighvsLow = Math.abs(dH-dL);
    var prevClosevsHigh = Math.abs(dC - dH);
    var prevClosevsLow = Math.abs(dC - dL);

    var nTTR = Math.max(HighvsLow, prevClosevsHigh, prevClosevsLow);

    if (vState == BARSTATE_NEWBAR){
    AryTTR.pop();
    AryTTR.unshift(nTTR);
    } else {
    AryTTR[0] = nTTR;
    }

    if (AryTTR[AryTTR.length-1] == null) return;

    var PATR = ref(-1); // Perious ATR
    if (PATR == null){
    var iSum = 0;
    for(var i = 0; i < AryTTR.length; i++){
    iSum = iSum + AryTTR[i];
    }
    return iSum/nInputPeriod;
    } else {
    return (PATR*(nInputPeriod-1)+nTTR)/nInputPeriod;
    }
    }

    Comment


    • #3
      Might also help to review this KB article on ATR from the EFS Help Center.

      Thanks.

      Comment

      Working...
      X