Announcement

Collapse
No announcement yet.

Updated FirstXminsHL.efs

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

  • Updated FirstXminsHL.efs

    How do I modify FirstXminsHL.efs so it will work with a specific time period (0930-1000) using a 24 hour time template? Also I would like to display the values for the additional lines on the charts, similar to the original lines. Thanks.

    Kevin

    The following is the subject code:

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("ACD System");
    setCursorLabelName("30m H", 0);
    setCursorLabelName("30m L", 1);
    setCursorLabelName("CUp", 2);
    setCursorLabelName("AUp", 3);
    setCursorLabelName("ADown", 4);
    setCursorLabelName("CDown", 5);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarFgColor(Color.blue, 2);
    setDefaultBarFgColor(Color.blue, 3);
    setDefaultBarFgColor(Color.blue, 4);
    setDefaultBarFgColor(Color.blue, 5);
    setDefaultBarThickness(3, 0);
    setDefaultBarThickness(3, 1);
    setDefaultBarThickness(3, 2);
    setDefaultBarThickness(3, 3);
    setDefaultBarThickness(3, 4);
    setDefaultBarThickness(3, 5);
    setPlotType(PLOTTYPE_FLATLINES, 0);
    setPlotType(PLOTTYPE_FLATLINES, 1);
    setPlotType(PLOTTYPE_FLATLINES, 2);
    setPlotType(PLOTTYPE_FLATLINES, 3);
    setPlotType(PLOTTYPE_FLATLINES, 4);
    setPlotType(PLOTTYPE_FLATLINES, 5);

    var fp1 = new FunctionParameter("nMin", FunctionParameter.NUMBER);
    fp1.setName("Number of Minutes");
    fp1.setLowerLimit(1);
    fp1.setDefault(30);

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

    var fp3 = new FunctionParameter("cColorH", FunctionParameter.COLOR);
    fp3.setName("High Color");
    fp3.setDefault(Color.blue);

    var fp4 = new FunctionParameter("cColorL", FunctionParameter.COLOR);
    fp4.setName("Low Color");
    fp4.setDefault(Color.red);

    var fp5 = new FunctionParameter("nTicksA", FunctionParameter.NUMBER);
    fp5.setName("Ticks for A");
    fp5.setLowerLimit(.01);
    fp5.setDefault(3)

    var fp6 = new FunctionParameter("nTicksC", FunctionParameter.NUMBER);
    fp6.setName("Ticks for C");
    fp6.setLowerLimit(.01);
    fp6.setDefault(3)

    var fp7 = new FunctionParameter("cColorCUp", FunctionParameter.COLOR);
    fp7.setName("C Up Color");
    fp7.setDefault(Color.blue);

    var fp8 = new FunctionParameter("cColorAUp", FunctionParameter.COLOR);
    fp8.setName("A Up Color");
    fp8.setDefault(Color.blue);

    var fp9 = new FunctionParameter("cColorADown", FunctionParameter.COLOR);
    fp9.setName("A Down Color");
    fp9.setDefault(Color.red);

    var fp10 = new FunctionParameter("cColorCDown", FunctionParameter.COLOR);
    fp10.setName("C Down Color");
    fp10.setDefault(Color.red);
    }

    var bEdit = true;
    var bActive = true;
    var nDayCntr = 0;

    var vStartTime = null;
    var vHigh = null;
    var vLow = null;
    var FirstBar = null;

    function main(nMin, nThickness, cColorH, cColorL, cColorCUp, cColorAUp, cColorADown, cColorCDown, nTicksA, nTicksC) {
    if (nMin == null) nMin = 30;
    if (bEdit == true) {
    nMin = Math.round(nMin);
    setCursorLabelName(nMin + "min H", 0);
    setCursorLabelName(nMin + "min L", 1);
    setDefaultBarThickness(nThickness, 0);
    setDefaultBarThickness(nThickness, 0);
    setDefaultBarFgColor(cColorH, 0);
    setDefaultBarFgColor(cColorL, 1);
    setDefaultBarFgColor(cColorCUp, 2);
    setDefaultBarFgColor(cColorAUp, 3);
    setDefaultBarFgColor(cColorADown, 4);
    setDefaultBarFgColor(cColorCDown, 5);
    bEdit = false;
    }

    if (getDay() != getDay(-1) || vHigh == null || vLow == null) {
    bActive = true;
    nDayCntr += 1;
    vStartTime = getValue("Time");
    vHigh = high();
    vLow = low();
    }
    FirstBar = getFirstBarIndexOfDay(vStartTime);
    var vTime = getValue("Time");

    // 3,600,000 milliseconds = 1 hour
    // 60,000 milliseconds = 1 minute
    if ((vTime - vStartTime)/60000 < nMin) {
    vHigh = Math.max(high(), vHigh);
    vLow = Math.min(low(), vLow);
    } else {
    bActive = false;
    }

    if (FirstBar != null) {
    drawLineRelative( FirstBar, vHigh, 0, vHigh, PS_SOLID, nThickness,cColorH, "Hline");
    drawLineRelative( FirstBar, vHigh+nTicksC, 0,vHigh+nTicksC, PS_SOLID, nThickness, cColorCUp, "CUp");
    drawLineRelative( FirstBar, vHigh+nTicksA, 0,vHigh+nTicksA, PS_SOLID, nThickness, cColorAUp, "AUp");
    drawTextRelative( 2, vHigh, vHigh.toFixed(2), cColorH, null, Text.VCENTER|Text.BOLD, null, 10, "High");
    drawLineRelative( FirstBar, vLow, 0, vLow, PS_SOLID, nThickness, cColorL, "Lline")
    drawLineRelative( FirstBar, vLow-nTicksA, 0,vLow-nTicksA, PS_SOLID, nThickness, cColorADown, "ADown");
    drawLineRelative( FirstBar, vLow-nTicksC, 0,vLow-nTicksC, PS_SOLID, nThickness, cColorCDown, "CDown");
    drawTextRelative( 2, vLow, vLow.toFixed(2), cColorL, null, Text.VCENTER|Text.BOLD, null, 10, "Low");
    }

    if (bActive == false) {
    return new Array((vHigh+nTicksA).toFixed(2),(vHigh+nTicksC).t oFixed(2),vHigh.toFixed(2), vLow.toFixed(2),
    (vLow-nTicksA).toFixed(2),(vLow-nTicksC).toFixed(2));
    }
    return null;
    }

  • #2
    Addditonally, is it possible to have multiple start and ending times (for example: 0930-1000 & 0000-0030) on the same chart? Thanks.

    Kevin
    Last edited by kevinmclark; 01-24-2006, 10:39 AM.

    Comment


    • #3
      Kevin
      The HiLo_firstXminutes.efs that is available here will compute the High and Low based on user defined Start/End times regardless of the Time Template used (see enclosed image). You could incorporate the logic of your script into that formula.
      If you are unfamiliar with programming in efs then you may want to contact one of the EFS Consultants and have them develop the study for you
      Alex

      Comment


      • #4
        Thanks for pointing me in the right direction.

        Comment

        Working...
        X