Announcement

Collapse
No announcement yet.

Support/Resistance Areas Background Color

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

  • Support/Resistance Areas Background Color

    I'm looking for a script that will color the background in the price pane between two prices. The intended result is a horizontal band of background color beteen price A and B.

    In total, the script should allow entry of 4 value ranges for support (Color 1 for support areas) (e.g. price A to B, C to D, E to F, G to H), and 4 value ranges for resistance (Color 2 for resistance areas) (e.g price I to J, K to L, M to N, O to P). Ideally, the 16 values making up the 8 ranges would be entered using Edit Studies > Formula Parameters.

    Edit Studies > Formula Parameters labels (in this order):
    R Level 4 Low Price High Price
    R Level 3
    R Level 2
    R Level 1
    S Level 1
    S Level 2
    S Level 3
    S Level 4

    I haven't seen horizontal background color changes in any script, but maybe it's possible to do. Thanks in advance for any help.

  • #2
    Lancer
    I don't know of a way of doing it all with one efs but it can be done running multiple copies of the efs enclosed below
    Alex



    PHP Code:
    function preMain(){
    setPriceStudy(true); 
    setStudyTitle("Background"); 
    setShowCursorLabel(false); 


        var 
    fp2 = new FunctionParameter("Upper"FunctionParameter.NUMBER);
        
    fp2.setLowerLimit(0);
        
    fp2.setDefault(1080);
        
        var 
    fp3 = new FunctionParameter("Lower"FunctionParameter.NUMBER);
        
    fp3.setLowerLimit(0);
        
    fp3.setDefault(1075);

    }

    function 
    main(Upper,Lower){

    if (
    1==1
    setBarBgColor(Color.lime,0,Lower,Upper); 


    return 
    null;

    Comment


    • #3
      Thanks Alexis. Why is it that multiple horizontal background color bands cannot be created using one EFS?

      Comment


      • #4
        Lancer
        FWIW you can paint multiple backgrounds using one efs. You just can't do it on the same bar.
        Alex



        PHP Code:
        function preMain(){
        setPriceStudy(true); 
        setStudyTitle("Background"); 
        setShowCursorLabel(false); 


            var 
        fp2 = new FunctionParameter("Upper"FunctionParameter.NUMBER);
            
        fp2.setLowerLimit(0);
            
        fp2.setDefault(1080);
            
            var 
        fp3 = new FunctionParameter("Lower"FunctionParameter.NUMBER);
            
        fp3.setLowerLimit(0);
            
        fp3.setDefault(1075);

        }

        function 
        main(Upper,Lower){

        if (
        getCurrentBarIndex()<-20
        setBarBgColor(Color.lime,0,Lower,Upper); 

        if (
        getCurrentBarIndex()>-20
        setBarBgColor(Color.red,0,1065,1070); 



        return 
        null;

        Comment


        • #5
          I wonder if the addBand command would help draw horizontal lines in the price pane?

          Comment


          • #6
            David
            Yes you could use addBand()

            PHP Code:
            function preMain(){
            setPriceStudy(true); 
            setStudyTitle("Price-Band"); 
            setShowCursorLabel(false); 
            }

            function 
            main(){

            addBand(1077.5,PS_SOLID,50,Color.red,1);

            return 
            null;

            However, because the value is that of the center of the band you would have to guess the thickness to encompass a specific range. Then as you scroll the chart the scale changes and so does the relative thickness of the band as in the examples below where the cursor is at the lower limit of the band in both charts.
            Alex



            Comment


            • #7
              Needing some help coding this (formula attached) to be able to set/change line values using the Edit Studies interface. The problem is that no formula parameter names/values show up in Edit Studies > Study Properties. What is needed to get line value input boxes to display?

              The EFS help center had a little bit on this topic, but not enough explanation to give me a solution. Thanks in advance for any help.
              Attached Files

              Comment


              • #8
                Re: Reply to post 'Support/Resistance Areas Background Color'

                try removing the study and re-adding it to the chart, looks ok here.

                ----- Original Message -----
                From: <[email protected]>
                To: <[email protected]>
                Sent: Monday, January 12, 2004 7:36 PM
                Subject: Reply to post 'Support/Resistance Areas Background Color'


                > Hello dloomis,
                >
                > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                >

                Comment


                • #9
                  The usual reload doesn't do it?, hmmm. OK, remove and reapply formula and now input boxes are there. great. Lines and labels are OK. One problem left; re. the study title. After inputting line values via Edit Studies, the study title text displayed in the price pane now also displays a string of all the inputted numeric values in parenthesis following the text. All that's needed is the just study title name; no values. How to suppress display of those numeric values in the study title?

                  Comment


                  • #10
                    Re: Reply to post 'Support/Resistance Areas Background Color'

                    setShowTitleParameters( false );
                    ----- Original Message -----
                    From: <[email protected]>
                    To: <[email protected]>
                    Sent: Monday, January 12, 2004 8:21 PM
                    Subject: Reply to post 'Support/Resistance Areas Background Color'


                    > Hello dloomis,
                    >
                    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    >

                    Comment


                    • #11
                      All looking good. Thank you David.

                      Comment


                      • #12
                        Contrary to what I originally thought it actually is possible to paint the background in multiple colors on the same bar.
                        See examples here
                        Alex

                        Comment

                        Working...
                        X