Announcement

Collapse
No announcement yet.

Lines at specific times

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

  • Lines at specific times

    I'm trying to draw a vertical line at 10:00am on my chart of the YM futures.
    I built the following EFS, and it checks out w/no syntax errors, but when I load it, it crashes.

    Any suggestions?

    JOHN


    ======================================

    function preMain() {

    setPriceStudy(true);
    setStudyTitle("Time Bars");
    setComputeOnClose(true);
    }

    function main() {

    if ( hour(0) == 10 && minute(0) == 0 )
    drawLineRelative(0, high(0)+1000, 0, 0, PS_SOLID, 1, Color.blue);

    return null;
    }

  • #2
    John
    FWIW I am getting the following syntax error when I load the script on a chart
    "Time Bars.efs, line 11: Invalid number of arguments (8) for drawLineRelative()"
    You need to add a TagID parameter with some counter (else it will only draw one line). See example below.
    Alex

    PHP Code:
    drawLineRelative(0high(0)+100000PS_SOLID1Color.blue"line"+getCurrentBarCount()); 

    Comment


    • #3
      Alex,

      Thanks for your speedy reply. That fixed it. That was weird how the syntax checker would OK it. I thought that that last parameter was optional. Oh well. It's working now. Here's my final little EFS I needed, in case anyone else wants to do similarly. I just use this for formatting my charts for printing a hardcopy each night. It's nice not to have to draw those lines manually any more.

      Thanks.

      JOHN

      ===========================================

      // This routine puts a vertical blue lines on the chart at 10am, noon, and 2pm

      function preMain() {

      setPriceStudy(true);
      setStudyTitle("Time Bars");
      setComputeOnClose(true);
      }

      function main() {

      if ( hour(0) == 10 && minute(0) == 0 )
      drawLineRelative(0, high(0)+1000, 0, 0, PS_DASHDOT, 1, Color.blue, "line"+getCurrentBarCount());

      if ( hour(0) == 12 && minute(0) == 0 )
      drawLineRelative(0, high(0)+1000, 0, 0, PS_DASHDOT, 1, Color.blue, "line"+getCurrentBarCount());

      if ( hour(0) == 14 && minute(0) == 0 )
      drawLineRelative(0, high(0)+1000, 0, 0, PS_DASHDOT, 1, Color.blue, "line"+getCurrentBarCount());

      return null;
      }

      Comment


      • #4
        John
        You are most welcome.
        There are a couple of changes that you could implement to simplify the code (and perhaps make it just a bit more efficient). In place of if(hour(0)...) try using if((getHour()*100)+getMinute()==1000). Also replace all instances of high(0)+1000 with Infinity*1
        Hope this helps
        Alex

        Comment

        Working...
        X