Announcement

Collapse
No announcement yet.

Time vertical lines

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Time vertical lines

    Hello all..

    i changed a efs i found on the fileshare to plot a vertical line on chart at specific times of the day.

    The problem is i want to do it on a volume chart and some times there isn't, for example a 0930 bar (us open). we get a 0929 and then a 0931. that gives no line at all.

    there is any way to alter the efs to fix it?

    tx in advance
    Attached Files

  • #2
    garaujo
    Here is a generic example of the logic that is required to do what you want.
    First create a global variable (called for example bDone) which you set initially to false eg
    PHP Code:
    var bDone false;//global variable

    function main(){ 
    Then inside main you set a condition that checks for a new bar and a change in day. You then use this condition to reset your bDone variable to false every time a new day begins
    PHP Code:
    function main(){

        if(
    getBarState()==BARSTATE_NEWBAR && day(0)!=day(-1)){
            
    bDone false;
        } 
    Once you have done this you can now set your condition that checks for the time to be equal or greater than the defined time. When that event occurrs you execute your commands and set bDone to true
    PHP Code:
    if(bDone==false && (hour(0)*100)+minute(0)>=930){
        
    setBarBgColor(Color.yellow);
        
    bDone true;

    Setting bDone to true ensures that those commands will be executed only once during that day because bDone will not be equal to false [which is one of the required conditions] until a new day occurrs. The key factor is that the logic is looking for the first bar time that is equal or greater than the one you define and not just equal to. This ensures that if there is no bar at exactly 9:30 your commands will still be executed at the next closest bar.
    You will need to repeat this logic for each event in which you wish to execute some commands.
    Alex

    Comment

    Working...
    X