Announcement

Collapse
No announcement yet.

Price at a specific time

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

  • Price at a specific time

    Hi,

    Each day I need to know the closing price at 2:30PM YESTERDAY to use in my EFS. Is this possible?

    Please help.

    Thank you.

  • #2
    Hi Bob,
    try this.
    Massimo

    var nCloseDay1=null, nCloseDay0=null;
    function main() {
    if (getCurrentBarIndex() != 0) { // Are historical bars
    if (getDay(0) != getDay(-1)) { // Is the first bar of a new day
    nCloseDay1=nCloseDay0;
    }
    if (getHour(0) == 14 && getMinute(0) == 30-getInterval(0)) { // Is your 2.30pm-inv bar
    nCloseDay0=close(0);
    }
    debugPrintln("Inv: "+getInterval()+" H: "+getHour(0)+" M: "+getMinute(0)+" - Close 2.30 pm yesterday : "+nCloseDay1);
    // nCloseDay1 is your value !!!
    }
    }

    Comment


    • #3
      FWIW, just a minor correction:

      replace:
      PHP Code:
              if (getHour(0) == 14 && getMinute(0) == 30 getInterval()) { // Is your 2.30pm-inv bar 
      which gives the close of the previous bar, with:
      PHP Code:
              if (getHour(0) == 14 && getMinute(0) == 30){ // Is your 2.30pm-inv bar 
      or just remove the " - getInterval()" which changes the minute comparison value by the interval (in essence it refers to the previous bar).

      Wayne

      Comment


      • #4
        Sorry waynecd,
        I don't agree !!!
        We need close of 2.30pm, not of the bar that starts at 2.30pm.
        Regards
        Massimo

        Comment


        • #5
          Thank you very much, that's great.

          Comment


          • #6
            Hi maxmax68,

            You are right, the close at 2:30 is the previous bars close instead of that for the 2:30 bar which starts at 2:30 and ends one interval later.

            Wayne
            Sorry waynecd,
            I don't agree !!!
            We need close of 2.30pm, not of the bar that starts at 2.30pm.
            Regards
            Massimo
            Last edited by waynecd; 12-03-2011, 06:08 AM.

            Comment

            Working...
            X