Announcement

Collapse
No announcement yet.

3rd bar volatility alert

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

  • 3rd bar volatility alert

    Would it be possible to get a formula that would indicate a second consecutive decline in range? This would in effect be a 3 bar pattern. Bar one as the reference bar, bar two smaller range than one, bar three smaller range than bar two. Bar three would be the indicated bar. Perhaps the 3rd bar could be painted blue or indicated by a dot etc. Hope I have made this clear. Thanks.

  • #2
    HC III
    If by range you mean High-Low with no other conditions then the enclosed efs should do what you asked. It will paint a bar in blue when the High-Low of the current bar is less than that of the preceeding two bars.
    Alex

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("3bar range");
        
    setShowCursorLabel(false);
        
    setColorPriceBars(true);
        
    setDefaultPriceBarColor(Color.black);
          
    }
    function 
    main() {

        if((
    high(0)-low(0))<(high(-1)-low(-1))&&(high(-1)-low(-1))<(high(-2)-low(-2)))
            
    setPriceBarColor(Color.blue);

    return;

    Comment


    • #3
      Alexis- thanks for your help. Yes I meant range and that Bar2 < Bar1 and Bar 3 < Bar2 making the 3rd bar the smallest range bar which is painted as it is the second consecutive reduction in range. Forgive my lack of knowledge, but how do I get your work into a .efs to use on my charts? Thanks again.

      Comment


      • #4
        HC III
        Copy the code that is contained inside the PHP box then in eSignal open a new Formula Editor window (Tools->EFS->Editor) and paste the contents in it. Save with a file name of your choice in any one of the subfolders of Formulas
        Alex

        Comment


        • #5
          Alexis- that worked great! Is it possible to maintain the green for up close and red for down close on the other bars instead of black? Thanks again.

          Comment


          • #6
            HC III
            That needs to be added to the script. When I have a free moment I will do that
            Alex

            Comment


            • #7
              HC III
              The enclosed revision also includes the commands to color the other bars
              Alex

              PHP Code:
              function preMain() {
                  
              setPriceStudy(true);
                  
              setStudyTitle("3bar range");
                  
              setShowCursorLabel(false);
                  
              setColorPriceBars(true);
                  
              setDefaultPriceBarColor(Color.black);
                    
              }
              function 
              main() {

                  if((
              high(0)-low(0))<(high(-1)-low(-1))&&(high(-1)-low(-1))<(high(-2)-low(-2))){
                      
              setPriceBarColor(Color.blue);
                  }else if(
              close(0)>open(0)){
                      
              setPriceBarColor(Color.lime);
                  }else if(
              close(0)<open(0)){
                      
              setPriceBarColor(Color.red);
                  }

              return;

              Comment


              • #8
                Alexis- the formula is just what I wanted and works great! You have made me very happy. This is the second time you have helped me with a request and both experiences have been the best I have had with e-signal. Many thanks.

                Comment


                • #9
                  Alex- would it be possible to also color Outside bars in this study? Thanks.

                  Comment


                  • #10
                    HC III
                    The enclosed revision also colors outside bars in cyan.
                    Alex

                    PHP Code:
                    function preMain() {
                        
                    setPriceStudy(true);
                        
                    setStudyTitle("3bar range");
                        
                    setShowCursorLabel(false);
                        
                    setColorPriceBars(true);
                        
                    setDefaultPriceBarColor(Color.black);
                          
                    }
                    function 
                    main() {

                        if((
                    high(0)-low(0))<(high(-1)-low(-1))&&(high(-1)-low(-1))<(high(-2)-low(-2))){
                            
                    setPriceBarColor(Color.blue);
                        }else if(
                    high(0)>high(-1)&&low(0)<low(-1)){
                            
                    setPriceBarColor(Color.cyan);
                        }else if(
                    close(0)>open(0)){
                            
                    setPriceBarColor(Color.lime);
                        }else if(
                    close(0)<open(0)){
                            
                    setPriceBarColor(Color.red);
                        }

                    return;

                    Comment


                    • #11
                      Alex- perfect! many thanks.

                      Comment


                      • #12
                        Alex- would it be possible to add another bar indication to the 3 bar range study? This would be 2 higher highs and closes with closes above their opens(green bars) followed by a lower high and a close below the previous 2 up closes. The 3rd bar would be the colored or indicated bar. Exactly the opposite for buys - 2 lower lows and closes followed by a higher low and close above the previous two down closes. This is basically a 3rd lower high or higher low 2 close reversal. Thanks again for your help. Henry

                        Comment


                        • #13
                          Henry
                          The enclosed revision should do what you asked. The thrd bar high is colored in magenta while the low is in green.
                          Alex

                          PHP Code:
                          function preMain() {
                              
                          setPriceStudy(true);
                              
                          setStudyTitle("3bar range");
                              
                          setShowCursorLabel(false);
                              
                          setColorPriceBars(true);
                              
                          setDefaultPriceBarColor(Color.black);
                                
                          }
                          function 
                          main() {
                              
                              if(
                          close(-2)>open(-2)&&close(-2)>close(-3)&&high(-2)>high(-3)&&
                                 
                          close(-1)>open(-1)&&close(-1)>close(-2)&&high(-1)>high(-2)&&
                                 
                          close(0)<open(0)&&close(0)<close(-2)&&high(0)<high(-1)){
                                     
                          setPriceBarColor(Color.magenta);
                              }else if(
                          close(-2)<open(-2)&&close(-2)<close(-3)&&low(-2)<low(-3)&&
                                 
                          close(-1)<open(-1)&&close(-1)<close(-2)&&low(-1)<low(-2)&&
                                 
                          close(0)>open(0)&&close(0)>close(-2)&&low(0)>low(-1)){
                                     
                          setPriceBarColor(Color.green);
                              }else if((
                          high(0)-low(0))<(high(-1)-low(-1))&&(high(-1)-low(-1))<(high(-2)-low(-2))){
                                  
                          setPriceBarColor(Color.blue);
                              }else if(
                          high(0)>high(-1)&&low(0)<low(-1)){
                                  
                          setPriceBarColor(Color.cyan);
                              }else if(
                          close(0)>open(0)){
                                  
                          setPriceBarColor(Color.lime);
                              }else if(
                          close(0)<open(0)){
                                  
                          setPriceBarColor(Color.red);
                              }

                          return;

                          Comment


                          • #14
                            Alex- when I went to apply the formula to the chart I got an error message that a syntax error had occured?

                            Comment


                            • #15
                              Henry
                              I just copied it from the post and loaded it in a chart and am not getting any errors (see image)
                              What is the syntax error?
                              Alex

                              Comment

                              Working...
                              X