Announcement

Collapse
No announcement yet.

Unale to get correct prices from open(0,sym("X,1"));

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

  • Unale to get correct prices from open(0,sym("X,1"));

    I have a one minute chart of "ES H11" and my "Time Template" is set for 24 hours in the advanced chart.

    I am trying to determine the current price (curPrice) of a stock, say "X", between 9:30 and 9:59, inclusive at one minute intervals. But the debugPrintln statement does not give the correct prices for the one minute times and is "null" for all previous days than today. The Day times are correct though. I can't for the life me figure out what I am doing wrong. This has to be an easy one, I think I am staring at the screen to long. Can someone help?

    PHP Code:
    debugClear()
    var 
    curPrice 0;
    var 
    closePrice 0;


    function 
    main() {
        var 
    ibarDay getDay(0);
        var 
    ibarHour getHour(0);
        var 
    ibarMinute getMinute(0);
        
        if (
    ibarHour == && ibarMinute >= 30 && ibarMinute <= 59) {
            
    curPrice open(0,sym("X,1"));
            
    closePrice close(0,sym("X,D"));
            
    debugPrintln(closePrice," closePrice= ",curPrice," curPrice= ",ibarDay," Day= ",ibarHour," Hour= ",ibarMinute," Minute= ");
        }
    return


  • #2
    Create a Time Template just like the "24 Hour" Time Template but increase the "# Days" box to a number greater than 0 and save it under a different name. Last set the charts Time Template to the one you just created.

    In case it isn't a typo, the symbol is "ES H1"

    Wayne
    Last edited by waynecd; 12-31-2010, 09:04 AM.

    Comment


    • #3
      Hi Wayne, thanks for the response. Did what you say and it still doesn't work.

      I did notice that if I place both symols (ES H1 and X) on the same chart, for some reason the opening time for X is at 8:30 and not 9:30 (the stock exchange time). If I only chart X by itself the opening time is 9:30 EST. My computer clock is set for EST. If I go to File - Preferences - Date/Time Settings the Exchange Timezone has a green dot in it (clicked on).

      Any suggestions as to how to correct this (move the times for symbol X so the times are set to EST in a chart of ES H1 and X, one minute)?

      Also, I can load ES H1 or ES H11 and get the same chart (they appear to be interchangable). If you do not use two digits to indicate the year, then how do read ES H01 (2001)?

      Thank you,
      Jack

      Comment


      • #4
        The following script on an "ES H1" chart (1 min or 5 min interval) with the following Time Template settings:

        Type: Intraday Default (the "User Defined" option didn't work for me either)
        # Days: 5
        Days: enabled Bars: Disabled
        Start Time: 0:00
        EndTime: 0:00

        with efs:

        PHP Code:
        debugClear();

        function 
        main() {
        var 
        curPrice 0;
        var 
        closePrice 0;
            var 
        ibarDay getDay(0);
            var 
        ibarHour getHour(0);
            var 
        ibarMinute getMinute(0);
            
            if (
        ibarHour == && ibarMinute >= 30 && ibarMinute <= 59) {
                
        curPrice open(0,sym("ES H1, 1"));
                
        closePrice close(0,sym("ES H1, D"));
                
        debugPrintln(closePrice," closePrice= ",curPrice," curPrice= ",ibarDay," Day= ",ibarHour," Hour= ",ibarMinute," Minute= ");
            }
        return

        outputs:
        Minute= 45 Hour= 9 Day= 31 curPrice= 1250.5 closePrice= 1254.25
        Minute= 30 Hour= 9 Day= 31 curPrice= 1250.75 closePrice= 1254.25
        Minute= 45 Hour= 9 Day= 30 curPrice= 1255 closePrice= 1254.5
        Minute= 30 Hour= 9 Day= 30 curPrice= 1256.5 closePrice= 1254.5
        Minute= 45 Hour= 9 Day= 29 curPrice= 1256.5 closePrice= 1255.75
        Minute= 30 Hour= 9 Day= 29 curPrice= 1255.75 closePrice= 1255.75
        Minute= 45 Hour= 9 Day= 28 curPrice= 1253.25 closePrice= 1254
        Minute= 30 Hour= 9 Day= 28 curPrice= 1254 closePrice= 1254
        Minute= 45 Hour= 9 Day= 27 curPrice= 1248.25 closePrice= 1253.25
        Minute= 30 Hour= 9 Day= 27 curPrice= 1248 closePrice= 1253.25
        Minute= 30 Hour= 9 Day= 27 curPrice= 1248 closePrice= 1253.25
        also try:
        PHP Code:
        debugClear();
        var 
        curPrice 0;
        var 
        closePrice 0;

        var 
        bInit false;
        var 
        vOpen null;
        var 
        vClose null;
        function 
        main() {
            var 
        xSymbol;
            if(!
        bInit){
                
        xSymbol getSymbol() + ", " 1;
                
        vOpen open(sym(xSymbol));
                
        xSymbol getSymbol() + ",  D";
                
        vClose close(sym(xSymbol));
                
        bInit true;
            }
            var 
        ibarDay getDay(0);
            var 
        ibarHour getHour(0);
            var 
        ibarMinute getMinute(0);
            var 
        Open_0 vOpen.getValue(0);
            var 
        Close_0 vClose.getValue(0);
            
            if (
        ibarHour == && ibarMinute >= 30 && ibarMinute <= 59) {
                
        curPrice Open_0;
                
        closePrice Close_0;
                
        debugPrintln(closePrice," closePrice= ",curPrice," curPrice= ",ibarDay," Day= ",ibarHour," Hour= ",ibarMinute," Minute= ");
            }
            return

        which outputs:

        Minute= 55 Hour= 9 Day= 31 curPrice= 1250.5 closePrice= 1254.5
        Minute= 50 Hour= 9 Day= 31 curPrice= 1250.75 closePrice= 1254.5
        Minute= 45 Hour= 9 Day= 31 curPrice= 1250.5 closePrice= 1254.5
        Minute= 40 Hour= 9 Day= 31 curPrice= 1250.75 closePrice= 1254.5
        Minute= 35 Hour= 9 Day= 31 curPrice= 1252 closePrice= 1254.5
        Minute= 30 Hour= 9 Day= 31 curPrice= 1251.75 closePrice= 1254.5
        Minute= 55 Hour= 9 Day= 30 curPrice= 1255 closePrice= 1254.5
        Minute= 50 Hour= 9 Day= 30 curPrice= 1256 closePrice= 1254.5
        Minute= 45 Hour= 9 Day= 30 curPrice= 1256.25 closePrice= 1254.5
        Minute= 40 Hour= 9 Day= 30 curPrice= 1256.5 closePrice= 1254.5
        Minute= 35 Hour= 9 Day= 30 curPrice= 1255.25 closePrice= 1254.5
        Minute= 30 Hour= 9 Day= 30 curPrice= 1254.5 closePrice= 1254.5
        Minute= 55 Hour= 9 Day= 29 curPrice= 1256.5 closePrice= 1255.75
        Minute= 50 Hour= 9 Day= 29 curPrice= 1256 closePrice= 1255.75
        Minute= 45 Hour= 9 Day= 29 curPrice= 1256 closePrice= 1255.75
        Minute= 40 Hour= 9 Day= 29 curPrice= 1255.75 closePrice= 1255.75
        Minute= 35 Hour= 9 Day= 29 curPrice= 1255.75 closePrice= 1255.75
        Minute= 30 Hour= 9 Day= 29 curPrice= 1256.75 closePrice= 1255.75
        Minute= 55 Hour= 9 Day= 28 curPrice= 1253.25 closePrice= 1254
        Minute= 50 Hour= 9 Day= 28 curPrice= 1253 closePrice= 1254
        Minute= 45 Hour= 9 Day= 28 curPrice= 1253.5 closePrice= 1254
        Minute= 40 Hour= 9 Day= 28 curPrice= 1254 closePrice= 1254
        Minute= 35 Hour= 9 Day= 28 curPrice= 1254 closePrice= 1254
        Minute= 30 Hour= 9 Day= 28 curPrice= 1255 closePrice= 1254
        Minute= 55 Hour= 9 Day= 27 curPrice= 1248.25 closePrice= 1253.25
        Minute= 50 Hour= 9 Day= 27 curPrice= 1247.25 closePrice= 1253.25
        Minute= 45 Hour= 9 Day= 27 curPrice= 1247.5 closePrice= 1253.25
        Minute= 40 Hour= 9 Day= 27 curPrice= 1248 closePrice= 1253.25
        Minute= 35 Hour= 9 Day= 27 curPrice= 1248.5 closePrice= 1253.25
        Minute= 30 Hour= 9 Day= 27 curPrice= 1247 closePrice= 1253.25
        Wayne
        Last edited by waynecd; 12-31-2010, 12:26 PM.

        Comment


        • #5
          To correct a typo in my previous post;
          The following script on an "ES H1" chart (1 min or 5 min interval) with the following Time Template settings:
          For the first "Formula Window" output in my previous post I used a 15 minute interval (not 1 min) and for the second one I used a 5 minute interval.

          Wayne

          Comment


          • #6
            Thanks Wayne, I undertood the time intervals you chose.

            I called eSignal and found out that all the eminis can be combined into one chart. It is called "ES #F". The eSignal rep said that the emini's open at 8:30, so when I overlay a stock on the emini chart it shows that it opens at 8:30 instead of 9:30 EST. I made a few adjustments to the program and (open begins at 8:30) and got it. It now reads correctly.

            Thank you for your time and input Wayne, really appreciate it. In fact all you guys that take the time to help out.

            Jack

            Comment


            • #7
              Glad you got it.

              Replacing the "H1" etc with "#F" loads the continuous contract for several futures such as the "ES", "YM", "6E" etc.

              The S&P emini "ES #F" hours are posted at: http://www.cmegroup.com/trading/equi...fications.html

              They are (Eastern Time):
              MON-THURS: 6:00 p.m.-4:15 p.m. & 4:30 p.m.-5:30 p.m.
              (Daily maintenance shutdown 5:30 p.m.-6:00 p.m.)
              SUN: 6:00 p.m.-4:15 p.m.

              So they are only closed from 4:15 pm to 4:30 pm and 5:30 pm to 6 pm on trading days.

              The pit trading starts at 9:30 am so that is when the higher volume starts. However, mostly when important news is expected, there can be good volume from a little before 8:30 am.

              So it can be traded most of the day with the caviat that the market is easier to manipulate (less predictable) during periods of low volume.

              Just my 2 cents.

              Wayne
              Last edited by waynecd; 01-02-2011, 12:24 PM.

              Comment

              Working...
              X