Announcement

Collapse
No announcement yet.

New Day Marker

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

  • New Day Marker

    I would like to add a vertical new day marker to the chart.

    Somehow the marker once appears once. For example, today is 27/4 and there is a marker for the 26/4-to-27/4 transition but none for the 25/4-to-26/4 transition). Would someone advise?

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("New Day marker");
    setShowCursorLabel(false);

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

    var fp2 = new FunctionParameter("cColor", FunctionParameter.COLOR);
    fp2.setName("Color");
    fp2.setDefault(Color.white);

    }

    function main(nThickness, cColor) {

    var vInt = getInterval();
    if (vInt == "D" || vInt == "W" || vInt == "M") return;

    if ( getBarState() == BARSTATE_NEWBAR ) {
    if ( getDay() != getDay(-1) && getDay(-1) != null )
    drawLineRelative(0, 0, 0, 15000, PS_DASH, nThickness, cColor, "HLine");

    }

    return;


    }

  • #2
    Hi Richard,
    Check "New Trading Day Marker.efs" in Jason's formulas under File Sharing. See if that helps.
    Diane

    Comment


    • #3
      Originally posted by Diane P
      Hi Richard,
      Check "New Trading Day Marker.efs" in Jason's formulas under File Sharing. See if that helps.
      Diane
      I hv used that EFS and set the time at 00:00:00 but sometimes the line disappears. It happens when there is no tick at 00:00:00.

      Comment


      • #4
        Richard

        Somehow the marker once appears once.
        That is happening because the TagID parameter you are using in the drawLineRelative() command is the same for all the graphic objects being created so only the last one is drawn on the chart. You need to use a TagID that is unique to each graphic object. That can be done using either a counter or a function that returns a value that is unique to each bar such as for example rawtime(0) or getCurrentBarCount()
        Replace the drawLineRelative() command in your script with the following
        PHP Code:
        drawLineRelative(00015000PS_DASHnThicknesscColor"HLine"+rawtime(0)); 
        and you will see that all the lines will be drawn (see enclosed screenshot)
        Alex

        Comment

        Working...
        X