Announcement

Collapse
No announcement yet.

Drawing a Horizontal Line between two User Defined intraday time points

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

  • Drawing a Horizontal Line between two User Defined intraday time points

    Hi,
    Is it possible to draw a Horizontal Line between two user chosen points in time (eg:10:00am to 3:00pm)?
    Thanks,
    Paul

  • #2
    Hi,

    Here is one way:

    PHP Code:
    //debugClear();

    function preMain() {
        var 
    aFPArray = new Array();
        
    setPriceStudy(true);
        
    //setStudyTitle("");
        
        
    var 0;
        
    aFPArray[x] = new FunctionParameter("StartTime"FunctionParameter.NUMBER);
        
    with(aFPArray[x++]) {
            
    setName("Start Time (930)");
            
    setLowerLimit(0);
            
    setUpperLimit(2400);
            
    addOption(300);                                        
            
    addOption(930);
            
    addOption(2000);                                    
           
    setDefault(930);
        }
        
    aFPArray[x] = new FunctionParameter("EndTime"FunctionParameter.NUMBER);
        
    with(aFPArray[x++]) {
            
    setName("End Time (1630)");
            
    setLowerLimit(0);
            
    setUpperLimit(2400);
            
    addOption(1130);                                    
            
    addOption(1615);
            
    addOption(300);                                    
            
    setDefault(1615);
        }
        
    aFPArray[x] = new FunctionParameter("nThickness"FunctionParameter.NUMBER);
        
    with(aFPArray[x++]) {
            
    setName("Line Thickness");
            
    setLowerLimit(1);
            
    setDefault(3);
        }
        
    aFPArray[x] = new FunctionParameter("cColorH"FunctionParameter.COLOR);
        
    with(aFPArray[x++]) {
            
    setName("High Color");
            
    setDefault(Color.blue);
        }
        
    aFPArray[x] = new FunctionParameter("DrawHowMany"FunctionParameter.STRING);
        
    with(aFPArray[x++]) {
            
    setName("Draw For:");
            
    addOption("Last Day");
            
    addOption("All Days");
            
    setDefault(3);
        }
    }

    var 
    vStartBar null;
    var 
    vEndBar null;
    var 
    startStop=false;
    function 
    main(StartTime,EndTimenThicknesscColorHDrawHowMany) {
        
    drawLineAtTimes(StartTime,EndTimenThicknesscColorHDrawHowMany);
    }
    function 
    drawLineAtTimes(StartTime,EndTimenThicknesscColorHDrawHowMany){
        var 
    nDate getYear()+""+(getMonth()+1)+getDay();
        var 
    barTime=((hour(0) * 100) + minute(0));
        var 
    numOfLines=1;
        
        if(
    DrawHowMany=="All Days"numOfLines=nDate;

        if(
    day(0)!=day(-1)){
            
    startStop=false;
        }
        if (
    barTime>=StartTime && EndTime>=barTime && !startStop){
            
    vStartBar=getCurrentBarCount();   
            
    startStop=true;
        }
        if (
    barTime>=StartTime && EndTime>=barTime) {//uncomment the drawLineRelative you want & comment out the drawLineRelative you don't want 
            
    vEndBar=getCurrentBarCount();
            
    //drawLineRelative( vStartBar-getCurrentBarCount(), close(vStartBar-getCurrentBarCount()), vEndBar-getCurrentBarCount(), close(vEndBar-getCurrentBarCount()), PS_SOLID, nThickness,cColorH, "xLine1"+numOfLines);//draws line from close of start bar to close of end bar
            
    drawLineRelativevStartBar-getCurrentBarCount(), close(vStartBar-getCurrentBarCount()), vEndBar-getCurrentBarCount(), close(vStartBar-getCurrentBarCount()), PS_SOLIDnThickness,cColorH"xLine2"+numOfLines);//draws line at close of start bar 
        
    }

        return;

    Wayne
    Last edited by waynecd; 03-13-2014, 09:03 PM.

    Comment


    • #3
      Thanks a lot Wayne, that does exactly what I want.

      I was trying out the study on Saturday, and as default it displayed the line for the previous day (Friday) at the times I desired. The "Draw For" Menu option of "All Days" also worked fine. The "Last Day" option drew the line on the Friday again, but with it being a weekend day, I presume this worked fine also. Changing the "Draw For" Menu number from "3" to any other number made no difference, as it still drew the line on Friday, so I am unsure what this number does or if it was working correctly for me (I guess it is to display a specific number of lines)?

      I was going to test these "Draw For" Menu options again this morning, with real time data being used by the study. Unfortunately I was unable to do this, as my computer developed a major issue on Sunday, and I have had to sent it back to the Manufacturer to be repaired.

      Paul

      Comment


      • #4
        Hi Paul,

        The "Draw For" default is a copy and paste error. It should default to either "Last Day" or "All Days", whichever you prefer.

        Wayne

        Comment

        Working...
        X