Announcement

Collapse
No announcement yet.

ID with NR4

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

  • ID with NR4

    Hi, I'm looking to expand the code below to distinguish between standard inside day bars and inside days which are also nr4 (narrowest range of the past 4 days). As it stands it will id all nr7, wr7, id & id with nr7. Can anyone please help me to add this condition to the code?



    /************************************************** **************************************************
    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.
    ************************************************** ************************************************** */
    var lowSoFar = Number.MAX_VALUE;
    var highSoFar = Number.MIN_VALUE;

    function preMain() {
    setPriceStudy(true);
    setColorPriceBars(true);
    setDefaultPriceBarColor(Color.grey);
    setStudyTitle(" ");
    setShowCursorLabel(false);
    }

    function main() {
    var vHigh = high();
    var vLow = low();
    var vPrevHigh = high(-1);
    var vPrevLow = low(-1);

    if(vHigh == null || vLow == null || vPrevHigh == null || vPrevLow == null) {
    return;
    }

    if (vHigh > vPrevHigh && vLow > vPrevLow) {
    setPriceBarColor(Color.RGB(0, 0xCC, 0));
    } else if (vHigh < vPrevHigh & vLow < vPrevLow) {
    setPriceBarColor(Color.red);
    } else if (vHigh > vPrevHigh && vLow < vPrevLow) {
    setPriceBarColor(Color.blue);
    } else if (vHigh < vPrevHigh && vLow > vPrevLow) {
    setPriceBarColor(Color.RGB(255, 173, 92));
    }

    if (getInterval() == "D" || getInterval() == "W" || getInterval() == "M") {
    // check for NR7 or WR7 days.
    var vHigh = getValue("High", 0, -7);
    var vLow = getValue("Low", 0, -7);
    var i;
    NR = 0;
    WR = 0;

    for(i = 0; i < 7; i++){
    WR = Math.max(WR, vHigh[i] - vLow[i]);
    if(i == 0)
    NR = vHigh[i] - vLow[i];
    else
    NR = Math.min(NR, vHigh[i] - vLow[i]);
    }
    if(vHigh[0] - vLow[0] == NR) {
    drawShapeAbsolute(getCurrentBarIndex(), high() + NR/2, Shape.DIAMOND, "", Color.red, Shape.TOP, getCurrentBarIndex());
    } else if(vHigh[0] - vLow[0] == WR) {
    drawShapeAbsolute(getCurrentBarIndex(), high() + NR/2, Shape.DIAMOND, "", Color.blue, Shape.TOP, getCurrentBarIndex());
    }
    }

    return;
    }
Working...
X