Announcement

Collapse
No announcement yet.

x Bars high/low

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

  • x Bars high/low

    Would someone please add a horizontal line showing the midpoint between the two points in this script? This efs draws horizontal lines at the high and low points reached during X number of bars from the open.




    function preMain() {
    setPriceStudy(true);
    setStudyTitle("x Bars High/Low ");
    setShowCursorLabel(false);

    var fp1 = new FunctionParameter("xBars", FunctionParameter.NUMBER);
    fp1.setName("Number of Bars");
    fp1.setLowerLimit(1);
    fp1.setDefault(20);

    var fp2 = new FunctionParameter("nThickness", FunctionParameter.NUMBER);
    fp2.setName("Line Thickness");
    fp2.setLowerLimit(1);
    fp2.setDefault(1);

    var fp3 = new FunctionParameter("cH", FunctionParameter.COLOR);
    fp3.setName("High Bar Color");
    fp3.setDefault(Color.darkgreen);

    var fp4 = new FunctionParameter("cL", FunctionParameter.COLOR);
    fp4.setName("Low Bar Color");
    fp4.setDefault(Color.maroon);
    }

    var nBars = 20;
    var BarCntr = 0;
    var vHigh = null;
    var vLow = null;

    function main(xBars, nThickness, cH, cL) {
    if (xBars != null) nBars = xBars;
    if (getBarState() == BARSTATE_NEWBAR) {
    if (getDay() != getDay(-1) && getDay(-1) != null) {
    BarCntr = 0;
    vHigh = high();
    vLow = low();
    }
    BarCntr += 1;
    }

    var h = high();
    var l = low();

    if (BarCntr <= nBars) {
    vHigh = Math.max(h, vHigh);
    vLow = Math.min(l, vLow);
    addBand(vHigh, PS_SOLID, Math.round(Math.abs(nThickness)), cH, "high");
    addBand(vLow, PS_SOLID, Math.round(Math.abs(nThickness)), cL, "low");
    }

    return;
    }

  • #2
    Here you go...

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("x Bars High/Low ");
    //setShowCursorLabel(false);

    var fp1 = new FunctionParameter("xBars", FunctionParameter.NUMBER);
    fp1.setName("Number of Bars");
    fp1.setLowerLimit(1);
    fp1.setDefault(20);

    var fp2 = new FunctionParameter("nThickness", FunctionParameter.NUMBER);
    fp2.setName("Line Thickness");
    fp2.setLowerLimit(1);
    fp2.setDefault(1);

    var fp3 = new FunctionParameter("cH", FunctionParameter.COLOR);
    fp3.setName("High Bar Color");
    fp3.setDefault(Color.darkgreen);

    var fp4 = new FunctionParameter("cL", FunctionParameter.COLOR);
    fp4.setName("Low Bar Color");
    fp4.setDefault(Color.maroon);
    }

    var nBars = 20;
    var BarCntr = 0;
    var vHigh = null;
    var vLow = null;

    function main(xBars, nThickness, cH, cL) {
    if (xBars != null) nBars = xBars;
    if (getBarState() == BARSTATE_NEWBAR) {
    if (getDay() != getDay(-1) && getDay(-1) != null) {
    BarCntr = 0;
    vHigh = high();
    vLow = low();
    }
    BarCntr += 1;
    }

    var h = high();
    var l = low();

    if (BarCntr <= nBars) {
    vHigh = Math.max(h, vHigh);
    vLow = Math.min(l, vLow);
    addBand(vHigh, PS_SOLID, Math.round(Math.abs(nThickness)), cH, "high");
    addBand(vLow, PS_SOLID, Math.round(Math.abs(nThickness)), cL, "low");
    }

    return ((vHigh+vLow)/2);
    }
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thank you Brad. Such a simple fix makes me feel guilty I don't know how to do the easy fixes on efs.

      Comment

      Working...
      X