Announcement

Collapse
No announcement yet.

TimeMarker

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

  • TimeMarker

    Good Morning,

    The following script is a cut up version of the timemarker from Alex. It draws lines on a tick chart but they do not stick like discussed in the Knowledge base. How do I make them stick relative to the time?

    Best Regards,

    Alan


    /************************************************** *******
    Draw time lines at 5 minute intervals
    ************************************************** ********/

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("Time Marker20Tnotime");
    setCursorLabelName("Time");
    setShowTitleParameters(false);
    checkVersion(7.9,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/Time Marker.efs","Time Marker.efs");

    var fp1 = new FunctionParameter("Interval", FunctionParameter.NUMBER);
    fp1.setLowerLimit(0);
    fp1.setDefault(5);

    var fp2 = new FunctionParameter("Offset", FunctionParameter.NUMBER);
    fp2.setDefault(0);

    var fp3 = new FunctionParameter("Lines", FunctionParameter.STRING);
    fp3.addOption("On");
    fp3.addOption("Off");
    fp3.setDefault("On");

    var fp3a = new FunctionParameter("Time", FunctionParameter.STRING);
    fp3a.addOption("On");
    fp3a.addOption("Off");
    fp3a.setDefault("On");

    var fp4 = new FunctionParameter("Cursor", FunctionParameter.STRING);
    fp4.addOption("false");
    fp4.addOption("true");
    fp4.setDefault("true");

    }

    var Cntr = 0;
    var x;
    var y;
    var z;
    var w;
    var pp;

    function main(Interval,Offset,Lines,Time,Cursor){

    setShowCursorLabel(eval(Cursor));

    if(isDWM()==true){
    setShowCursorLabel(false);
    return;
    }

    if(getBarState()==BARSTATE_NEWBAR){
    Cntr += 1;
    }

    x = (getHour()*1)+Offset;
    y = getMinute()*1;
    w = getSecond()*1;


    if(x>=24) x = x-24;
    if(x<0) x = 24+x;
    if(x<5) x = "0"+x;
    if(y<5) y = "0"+y;

    z = x+":"+y+":"+w;

    if(Lines=="On"){
    if(Cntr == 1){
    drawLineRelative(0,-30,0,99999,PS_SOLID, 1, Color.lightgrey,"Time"+Cntr);
    pp = 1;
    }




    if(Cntr == (pp + 6)){
    drawLineRelative(0,-30,0,99999,PS_SOLID, 1, Color.lightgrey,"Times"+Cntr);
    pp = Cntr;
    }

    }

    return z+"";
    }

  • #2
    Alan
    I am not sure I understand what you mean by "not sticking". As far as I can see the lines are being drawn every 6th bar which is what you appear to be setting in your conditions ie if(Cntr == (pp + 6)){. Those lines then remain fixed in that position once they are drawn
    To make it easier to understand what the efs is doing you may want to color one set of lines in a different color.
    Alex

    Comment


    • #3
      Timemarker

      Good Afternoon,

      In the orginal script, the line is drawn in a position relative to the x axis time. As the chart advances from right to left, the line sticks to the location of the time and advances in sync with the time. The modified script spaces the lines correctly but the line does not stay in sync with the time.

      Best regards,

      Alan

      Comment


      • #4
        Alan
        You are not using any time based conditions to draw your lines. You are only using the bar counter and the conditions are to draw a line every 6th bar.
        The only place where you are looking at time is to compute the variable z which you return as a string and displays in the Cursor Window the time stamp for that bar.
        Alex

        Comment

        Working...
        X