Announcement

Collapse
No announcement yet.

How do I get my program to only read the data for the first hour of trading?

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

  • How do I get my program to only read the data for the first hour of trading?

    My goal is to only work with data between the hours of 9:30 and 10:30 EST and I don't want to look at the rest of the data. I found DateRange.efs by eSignal's Project Manager Jason K. and modified as shown below. I changed it to hours and minutes instead of days, months, and years. Only problem is the market opens at 9:30 and is not an even number (ie, 9:00, or 10:00, or 11:00 etc.) so I can get a half hour of data or one and a half hours.

    Anyone have any ideas how to set this up so I only look at the first hour of the trading day?

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Date Range");
        
    setShowCursorLabel(false);
        
        var 
    fp1 = new FunctionParameter("startH"FunctionParameter.NUMBER);
        
    fp1.setName("Start Hour");
        for (var 
    1<=24; ++i) {
            
    fp1.addOption(i);
        }
        var 
    fp2 = new FunctionParameter("startM"FunctionParameter.NUMBER);
        
    fp2.setName("Start Minute");
        for (var 
    1<=60; ++i) {
            
    fp2.addOption(i);
        }
        
    fp2.setDefault(0);
        
        var 
    fp3 = new FunctionParameter("endH"FunctionParameter.NUMBER);
        
    fp3.setName("End Hour");
        for (var 
    .5<=24; ++i) {
            
    fp3.addOption(i);
        }
        
    fp3.setDefault(24);
        
        var 
    fp4 = new FunctionParameter("endM"FunctionParameter.NUMBER);
        
    fp4.setName("End Minute");
        for (var 
    1<=60; ++i) {
            
    fp4.addOption(i);
        }
        
    fp4.setDefault(60);
    }

    function 
    main(startHstartMendHendM) {
        var 
    barHour getHour(0);
        var 
    barMinute getMinute(0);
        
        if (
    barMinute startM || barMinute endM) return;
        if (
    barHour startH || barHour endH) return;
        
        
        
    // Insert code for back testing here
        
        
    setBarBgColor(Color.grey);
        
        return;


  • #2
    Re: How do I get my program to only read the data for the first hour of trading?

    WantToLearn
    See the enclosed screenshot for an example of a simple way to do what you are trying to accomplish
    Also try searching the forums and you should find several other examples as the topic has been covered at length before
    Alex




    Originally posted by WantToLearn
    My goal is to only work with data between the hours of 9:30 and 10:30 EST and I don't want to look at the rest of the data. I found DateRange.efs by eSignal's Project Manager Jason K. and modified as shown below. I changed it to hours and minutes instead of days, months, and years. Only problem is the market opens at 9:30 and is not an even number (ie, 9:00, or 10:00, or 11:00 etc.) so I can get a half hour of data or one and a half hours.

    Anyone have any ideas how to set this up so I only look at the first hour of the trading day?

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Date Range");
        
    setShowCursorLabel(false);
        
        var 
    fp1 = new FunctionParameter("startH"FunctionParameter.NUMBER);
        
    fp1.setName("Start Hour");
        for (var 
    1<=24; ++i) {
            
    fp1.addOption(i);
        }
        var 
    fp2 = new FunctionParameter("startM"FunctionParameter.NUMBER);
        
    fp2.setName("Start Minute");
        for (var 
    1<=60; ++i) {
            
    fp2.addOption(i);
        }
        
    fp2.setDefault(0);
        
        var 
    fp3 = new FunctionParameter("endH"FunctionParameter.NUMBER);
        
    fp3.setName("End Hour");
        for (var 
    .5<=24; ++i) {
            
    fp3.addOption(i);
        }
        
    fp3.setDefault(24);
        
        var 
    fp4 = new FunctionParameter("endM"FunctionParameter.NUMBER);
        
    fp4.setName("End Minute");
        for (var 
    1<=60; ++i) {
            
    fp4.addOption(i);
        }
        
    fp4.setDefault(60);
    }

    function 
    main(startHstartMendHendM) {
        var 
    barHour getHour(0);
        var 
    barMinute getMinute(0);
        
        if (
    barMinute startM || barMinute endM) return;
        if (
    barHour startH || barHour endH) return;
        
        
        
    // Insert code for back testing here
        
        
    setBarBgColor(Color.grey);
        
        return;

    Comment

    Working...
    X