Announcement

Collapse
No announcement yet.

Return close from specific time

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

  • Return close from specific time

    I am using the current formula to return the close from the daily chart. However I would like to also return the price from a specific time of day (19:00). Is there a way to replace the close of Daily bar to return this price?
    I only use this on an intraday chart

    Thanks in Advance

    PHP Code:

    var vLastAlert = -1;



    function 
    preMain() {
      
      
        
    setPriceStudy(false);
        
    setStudyTitle("Satosan Arb2");
        
    setCursorLabelName("?"0);
        
    setDefaultBarStyle(PS_SOLID0);
        
    setDefaultBarFgColor(Color.red0);
        
    setDefaultBarThickness(20);
        
    setPlotType(PLOTTYPE_LINE0);

    }

    function 
    main() {
      

        return (
    close() - close(0,inv("D"))) / close(0,inv("D"));

    }

    function 
    postMain() {
     
     
    }

        function 
    onAction1() {
            
    vLastAlert 1;
        } 

  • #2
    Hi, after a bit of snooping around on the
    forum, I found the following that does what I need. However, this example is returning the value from the Previous day. How can I have it return today's 2:30 (not yesterdays)?

    PHP Code:
    var nCloseDay1=nullnCloseDay0=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 !!!
    }

    Last edited by maninjapan; 12-12-2011, 06:40 AM.

    Comment


    • #3
      Actually I have been able to fix it by using the following

      PHP Code:
      function main() {

      nCloseDay1=nCloseDay0

      if (
      getHour(0) == 15 && getMinute(0) == 30-getInterval(0)) { // Is your 3.30pm-inv bar
      nCloseDay0=close(0);
      }
       return (
      nCloseDay1)



      Comment

      Working...
      X