Announcement

Collapse
No announcement yet.

When getOpen is not defined because of missing bar(s), how to get around it.

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

  • When getOpen is not defined because of missing bar(s), how to get around it.

    I have a chart showing SUN=N. For those that don't know, the =N is for data on the NYSE only. I am looking at the opening price (bar) for stocks on the NYSE only.

    Here is the problem, sometimes the stock opens at 9:30 EST, sometimes it can take 10 minutes or longer before it officially opens on the NYSE. This causes a problem in my program beause there is no bar(s) until it opens. So I tell my program to open(0) at 9:30 AM and there is no bar it gives me this error message: "ReferenceError: getOpen is not defined"

    I know this is easy for most of you but I have spent hours searching and can not find an asnwer. Any help would be appreciated.

    My code (lines 19 an 27 cause the problems, highlighted with //******)
    PHP Code:
    debugClear()

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Rick's First Hour");
    }
        
    var 
    stockOpen null;
        
    function 
    main() {
        var 
    ibarHour getHour(0);
        var 
    ibarMinute getMinute(0);
        var 
    ibarHrMin = ((getHour(0) * 100) + getMinute(0));
        var 
    ibarDay getDay(0);
        var 
    ibarMonth getMonth(0);
        var 
    ibarYear getYear(0);
        
        if (
    ibarHrMin >= 930 && ibarHrMin <= 935) {
            if(
    getOpen(0) == undefined || getOpen(0) == null); return  //******
            
    stockOpen getOpen(0);
            
    MaxPrice getOpen(0);
            
    MinPrice getOpen(0);        
        }
        
        if (
    ibarHrMin >= 931 && ibarHrMin <= 1000) {
            
    barTime = (getHour(0) * 100) + getMinute(0);
            if(
    getOpen(0) == undefined || getOpen(0) == null); return   //******
            
    curPrice getOpen(0);
            if(
    curPrice MaxPrice) {
                
    MaxPrice curPrice;
                
    MaxPrice1 curPrice stockOpen;
            }
            
            if(
    open(0) < MinPrice) {
                
    MinPrice curPrice;
                
    MinPrice1 curPrice stockOpen;
                
    MinTime barTime;
            }
        
    debugPrintln(ibarDay," Day= ",ibarMonth," Month= ",ibarYear,"  Year= ",stockOpen," stockOpen= ",MaxPrice1"MaxPr= ");
        }    


  • #2
    Just at a glance, try replacing;

    PHP Code:
    getOpen(0
    with:

    PHP Code:
    open(0
    Then add a global variable named "MaxPrice1 = null;" outside of main as:

    PHP Code:
    var stockOpen null;
    var 
    MaxPrice1 null;
        
    function 
    main() {
    ... 
    I would also comment out:

    PHP Code:
    ...
            
    //if(open(0) == undefined || open(0) == null); return  //******

    ...
            
    //if(open(0) == undefined || open(0) == null); return   //******

    ... 

    Wayne
    Last edited by waynecd; 12-27-2010, 07:31 AM.

    Comment


    • #3
      Yes, it works. Thank you Wayne!! Guess I need to understand the differences between getOpen() and open(). I will research it.

      Once again, thank you for taking the time to explain it.
      Jack

      Comment


      • #4
        Glad it worked.

        "getOpen() " is not an efs function.

        Consider a study of the following tutorials:



        and the knowledge base:



        and KB searches:



        Also, SteveHare2003 lists javascript links that I have found to be very useful. See one of his posts at:



        Wayne
        Last edited by waynecd; 12-27-2010, 05:58 PM.

        Comment

        Working...
        X