Announcement

Collapse
No announcement yet.

Verticle Line EFS

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

  • Verticle Line EFS

    Hello,

    I could use some help with an EFS I am trying to make.
    Basically I want the EFS to draw a verticle line every day at user defined time or times.

    I tried using the wizard for this but when I enter the global hour then == it will not let me place the time variable in the next box.

    Maybe I'm approaching this wrong, and maybe I shouldn't be using the wizard?

    I've used the wizard in the past with good results, any help is greatly appreciated.

  • #2
    Here is an EFS file that will do that:
    PHP Code:
    function preMain() 
    {
        
    setPriceStudy(true);
        
    setStudyTitle("New Trading Day Marker");
        
    setShowCursorLabel(false);
        
    setComputeOnClose(true);
        
        var 
    fp = new Array(3);
        
    fp[0] = new FunctionParameter("nHr"FunctionParameter.STRING);
        
    fp[1] = new FunctionParameter("nMin"FunctionParameter.STRING);
        
    fp[2] = new FunctionParameter("nSec"FunctionParameter.STRING);
        
        for (
    03; ++j) {
            for (
    060; ++i) {
                var 
    num i+"";
                if (
    10num "0"+i;
                if (
    24 && == 0) {
                    
    fp[j].addOption(num);
                } else {
                    
    fp[j].addOption(num);
                }
            }
        }
        
        
    fp[0].setName("Set Hour");
        
    fp[1].setName("Set Minute");
        
    fp[2].setName("Set Second");

        
    fp[0].setDefault("09");
        
    fp[1].setDefault("30");
        
    fp[2].setDefault("00");
    }

    var 
    vHr null;
    var 
    vMin null;
    var 
    vSec null;
    var 
    newDay true;
    var 
    dayCntr 0;

    function 
    main(nHrnMinnSec) {
        var 
    nState getBarState();
        var 
    vInt getInterval();
        if (
    vInt == "D" || vInt == "W" || vInt == "M") return;
        
        if (
    nState == BARSTATE_NEWBAR) {
            if (
    newDay == false && getDay() != getDay(-1) && getDay(-1) != nullnewDay true;
            if (
    newDay == true) {
                var 
    barHr getHour()+"";
                if (
    barHr != null && barHr 10barHr "0"+barHr;
                var 
    barMin getMinute()+"";
                if (
    barMin != null && barMin 10barMin "0"+barMin;
                var 
    barSec getSecond()+"";
                if (
    barSec != null && barSec 10barSec "0"+barSec;
                if(
    barHr >= nHr && barMin >= nMin && barSec >= nSec) {
                    
    drawLineRelative(0,0,0,99999,PS_SOLID1Color.lightgrey"NewDay"+dayCntr);
                    
    //drawShapeRelative(0, 5, Shape.DIAMOND, null, Color.blue, 
                        //Shape.RELATIVETOBOTTOM, "NewDay"+dayCntr);
                    
    dayCntr += 1;
                    
    newDay false;
                }
            }
        }    
        return;

    Save the code into two separate EFS files and then load them to a chart and then set one of them to the open time and one of them to the close time.

    The result will be this:

    Comment


    • #3
      verticle lines efs

      Hi thanks for the reply,

      This is close to what I was looking for, but I was looking to also plug in reversal times, i.e. 9:30, 10:30, etc.

      Comment

      Working...
      X