Announcement

Collapse
No announcement yet.

Help With Plotting Only Todays Open Info, Please

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

  • Help With Plotting Only Todays Open Info, Please

    Good Morning,
    I'm trying to plot the prices from open downward & from open upward for current day only.However, the previous days show up as well. Is there some way I can show only current day open? Thank you.
    Diane
    Attached Files

  • #2
    Diane
    Here is what you need to do.
    Create a global variable [ie outside of preMain() and main()] called bCurrentDay and set it initially to false eg
    PHP Code:
    var bCurrentDay false;//copy this line

    function main(){//do not copy this line. It is here only as a reference

    //rest of your code 
    Then at beginning of main() insert the code enclosed below. This will make your script plot/draw only today's line/values .
    Alex

    PHP Code:
    function main(){//do not copy this line. It is here only as a reference
    //copy the following code block
        
    if(getBarState()==BARSTATE_ALLBARS){
            
    bCurrentDay=false;
        }
        if (
    bCurrentDay == false && getDay(0) != getDay(-1)){ 
            var 
    xTime getValue("time");
            var 
    xDate = new Date(); 
            var 
    sTime = (xTime.getMonth()+1+"/"+xTime.getDate()+"/"+xTime.getFullYear()); 
            var 
    sToday = (xDate.getMonth()+1+"/"+xDate.getDate()+"/"+xDate.getFullYear()); 
            if ( 
    sTime == sToday ) { 
                
    bCurrentDay true
            } 
        } 
        if (
    bCurrentDay==false){
            return;
        }  

        
    //rest of your code 




    Originally posted by Diane P
    Good Morning,
    I'm trying to plot the prices from open downward & from open upward for current day only.However, the previous days show up as well. Is there some way I can show only current day open? Thank you.
    Diane

    Comment


    • #3
      Diane
      In addition to what I suggested in my previous message you could also simplify your script as follows.
      In this section of code
      PHP Code:
      var vTime=getValue("Time");
      var 
      OpenD open(inv("D"));
      var 
      vFirstIndex getFirstBarIndexOfDay(vTime,getSymbol()+",D");
      if(
      vFirstIndex!=null && getDay(0)!=getDay(-1)){  
          
      debugPrintln(getCurrentBarIndex()+" "+vFirstIndex);
          
      vTodaysOpen=getValueAbsolute("open",vFirstIndex,getSymbol()+",D");

      delete all the lines except var OpenD = open(inv("D"));
      Then in what will remain of your original script replace each instance of vTodaysOpen with OpenD.getValue(0)
      Alex

      Comment


      • #4
        Hi Alex,
        Thank you so much for helping me with this. Your answer solved my problem! I really appreciate the simplification, too. You are THE best! Have a great evening.
        Diane

        Comment


        • #5
          Diane
          You are most welcome and thank you for the compliment.
          Alex

          Comment

          Working...
          X