Announcement

Collapse
No announcement yet.

Daily High / Daily Low

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

  • Daily High / Daily Low

    Hi

    Is there an easy way to get the Daily High / Low of a certain product? I'm developing an automated trading strategy and one of the criteria is that the market must be at least X points away from the daily high for a long signal.

    Thanks

  • #2
    laocoon
    All you need to do is add a simple condition to your strategy such as for example
    if(close(0) < high(0, inv("d"))-10)
    which will check for current price to be less than daily High - 10
    Alex

    Comment


    • #3
      Thanks for your reply Alex, this should do the trick....

      Comment


      • #4
        Originally posted by Alexis C. Montenegro
        laocoon
        All you need to do is add a simple condition to your strategy such as for example
        if(close(0) < high(0, inv("d"))-10)
        which will check for current price to be less than daily High - 10
        Alex
        Alex,

        I played around with the inv function but I'm probably missing something because I'm getting a "loading data..." message in the cursor window...whenever I include it into my code. I even used the bit of code you provided in your last post, but the result was the same. I'm a bit lost I must say....

        Thanks for your reply.

        rob

        Comment


        • #5
          rob
          You may want to provide an example of the code you are using and some information regarding the interval of the chart, the Time Template settings (for both the chart and external interval), etc.
          Also when you were seeing the "Loading..." message could you get a chart for the external interval that was being called?
          Alex

          Comment


          • #6
            Originally posted by Alexis C. Montenegro
            rob
            You may want to provide an example of the code you are using and some information regarding the interval of the chart, the Time Template settings (for both the chart and external interval), etc.
            Also when you were seeing the "Loading..." message could you get a chart for the external interval that was being called?
            Alex

            Alex

            Thanks for your reply. Before I post a bit of my code, I'd like to clarify something because this might be the source of my error: when you say "the chart and the external interval..." I take it you're using two different intervals whereas I want to use only one. My strategy is loaded on a 5 min chart (24h time template) and I'm looking to retrieve the daily high/low of the current session on that same interval....is this feasible?

            Comment


            • #7
              rob

              when you say "the chart and the external interval..." I take it you're using two different intervals
              That is correct in as much as I was referring to using inv() in the if(close(0) < high(0, inv("d"))-10) conditional statement I suggested in an earlier message
              The inv() function allows you to run a chart on an interval while retrieving the value of a price series or study that is based on a different interval.

              My strategy is loaded on a 5 min chart (24h time template) and 'm looking to retrieve the daily high/low of the current session on that same interval....is this feasible?
              The easiest way to do that using inv() would be to use high(inv("d")) and low(inv("d")) which will return the daily High and Low regardless of the interval being charted.
              If instead you want to build the daily High and Low using only the chart data then see Session HiLo.efs posted in this thread
              Alex

              PHP Code:
              function preMain(){
                  
              setPriceStudy(true);
                  
              setCursorLabelName("High",0);
                  
              setCursorLabelName("Low",1);
              }
               
              function 
              main(){
               
                  var 
              xHigh high(inv("d"));
                  var 
              xLow  low(inv("d"));
                  
                  return new Array (
              xHighxLow);

              Comment


              • #8
                Alexis or anyone...

                What's the reason

                PHP Code:
                    xHigh high(  inv("D") );
                    
                xLow  lowinv("D") ); 
                do NOT plot like tHigh and tLow?

                Still learning EFS.

                Thanking You in Advance


                PHP Code:

                function preMain(){
                    
                setPriceStudy(true);
                    
                setCursorLabelName("High-A",0);
                    
                setCursorLabelName("Low-A",1);

                    
                setCursorLabelName("High-T",2);
                    
                setCursorLabelName("Low-T",3);


                    
                setDefaultBarThickness(2,0); 
                    
                setDefaultBarThickness(2,1); 
                    
                setDefaultBarThickness(2,2); 
                    
                setDefaultBarThickness(2,3); 
                }
                 

                var 
                tInit false ;

                    var 
                xHigh null ;
                    var 
                xLow  null ;

                    var 
                tHigh null ;
                    var 
                tLow  null ;

                function 
                main(){
                 

                if( 
                tInit == false ) {
                    
                xHigh high(  inv("D") );
                    
                xLow  lowinv("D") );
                    
                tInit true ;
                }


                    if(
                getBarState()==BARSTATE_NEWBAR && getDay(0)!=getDay(-1)) {
                        
                tHigh high(0);
                        
                tLow low(0);
                    }


                if( 
                high(0) > tHigh ) { tHigh high(0); }

                if( 
                low(0) < tLow ) { tLow low(0); }


                     
                setBarFgColor(Color.green0);
                     
                setBarFgColor(Color.red1);
                     
                setBarFgColor(Color.darkgreen2);
                     
                setBarFgColor(Color.maroon3); 

                    return new Array ( 
                xHigh.getValue(0) , xLow.getValue(0) , tHightLow );

                Attached Files

                Comment


                • #9
                  buzzhorton
                  The difference is due to the fact that xHigh and xLow reference the daily bar which returns a single data point per day across all the historical bars of the corresponding lower interval.
                  Alex

                  Comment

                  Working...
                  X