Announcement

Collapse
No announcement yet.

Bollinger Bands with color back ground

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

  • Bollinger Bands with color back ground

    Hi,
    Please, could someone help me to put a diferent color between the bands like a back ground pane?
    Last edited by Barros; 12-10-2006, 09:42 AM.

  • #2
    Barros
    To color the background in between values you need to use the optional yMin and yMax parameters in the setBarBgColor() function (see the link for the description and syntax)
    For an example of how to implement these parameters see the efs attached to this post.
    Alex

    Comment


    • #3
      I tryed this way, but there is a problem.
      Please, could you help me?


      This sample eSignal Formula Script (EFS) may be modified and saved under a new
      filename; however, eSignal is no longer responsible for the functionality once modified.
      eSignal reserves the right to modify and overwrite this EFS file with each new release.
      ************************************************** ************************************************** */
      var study = new BollingerStudy(20, "Close", 2.0);

      function preMain() {
      setPriceStudy(true);

      setDefaultBarFgColor(Color.blue, 0); // upper
      setDefaultBarFgColor(Color.red, 1); // basis
      setDefaultBarFgColor(Color.blue, 2); // lower
      }

      function main() {
      var vUpper = study.getValue(BollingerStudy.UPPER);
      var vBasis = study.getValue(BollingerStudy.BASIS);
      var vLower = study.getValue(BollingerStudy.LOWER);

      return new Array(vUpper, vBasis, vLower);
      }

      Insert your code following this text block
      Use var vUpper = study.getValue(BollingerStudy.UPPER) and
      var vBasis = study.getValue(BollingerStudy.BASIS) and
      var vLower = study.getValue(BollingerStudy.LOWER) for your code
      **************************************************/
      setBarBgColor(Color.yellow,1,vEnv.getValue(Bolling erStudy.LOWER),vEnv.getValue(BollingerStudy.UPPER) );
      Last edited by Barros; 12-12-2006, 03:09 PM.

      Comment


      • #4
        Barros,

        Your setBarBgColor line needs to be before the return new Array line. Something like the following.

        function main() {
        var vUpper = study.getValue(BollingerStudy.UPPER);
        var vBasis = study.getValue(BollingerStudy.BASIS);
        var vLower = study.getValue(BollingerStudy.LOWER);

        setBarBgColor(Color.yellow,1,vLower,vUpper));
        return new Array(vUpper, vBasis, vLower);
        }
        Last edited by smeyer55; 12-12-2006, 06:31 PM.

        Comment


        • #5
          A new problem

          Thanks for the help, but now I have a new problem:

          After I put ir suggestion on, apeared a error:

          .......^
          Bollinger|BuiltinBB Colors. efs. line 1:
          SintaxError: missing ; before statement:
          This sample eSignal Formula Script (EFS) may
          be modified and saved under a new


          /************************************************** *******
          Alexis C. Montenegro © October 2003
          Use and/or modify this code freely. If you redistribute it
          please include this and/or any other comment blocks and a
          description of any changes you make.
          ************************************************** ********/

          var vBB = null;

          function preMain() {
          setPriceStudy(true);
          setStudyTitle("BollingerBand");
          setCursorLabelName("BB-Upr", 0);
          setCursorLabelName("BB-Bas", 1);
          setCursorLabelName("BB-Lwr", 2);
          setDefaultBarFgColor(Color.blue, 0);
          setDefaultBarFgColor(Color.red, 1);
          setDefaultBarFgColor(Color.blue, 2);
          setDefaultBarThickness(1,0);
          setDefaultBarThickness(1,1);
          setDefaultBarThickness(1,2);

          var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
          fp1.setLowerLimit(1);
          fp1.setDefault(20); //Edit this value to set a new default

          var fp2 = new FunctionParameter("StdDev", FunctionParameter.NUMBER);
          fp2.setLowerLimit(0);
          fp2.setDefault(2); //Edit this value to set a new default

          var fp3 = new FunctionParameter("Source", FunctionParameter.STRING);
          fp3.setName("Source");
          fp3.addOption("Close");
          fp3.addOption("High");
          fp3.addOption("Low");
          fp3.addOption("Open");
          fp3.addOption("HL/2");
          fp3.addOption("HLC/3");
          fp3.addOption("OHLC/4");
          fp3.setDefault("Close"); //Edit this value to set a new default

          }

          function main() {
          var vUpper = study.getValue(BollingerStudy.UPPER);
          var vBasis = study.getValue(BollingerStudy.BASIS);
          var vLower = study.getValue(BollingerStudy.LOWER);

          setBarBgColor(Color.yellow,1,vLower,vUpper));
          return new Array(vUpper, vBasis, vLower);
          }

          /*************************************************
          Insert your code following this text block
          Use vBB.getValue(BollingerStudy.UPPER) and
          vBB.getValue(BollingerStudy.BASIS) and
          vBB.getValue(BollingerStudy.LOWER) for your code
          **************************************************/


          return new Array (vBB.getValue(BollingerStudy.UPPER),vBB.getValue(B ollingerStudy.BASIS),vBB.getValue(BollingerStudy.L OWER));
          }
          Last edited by Barros; 12-13-2006, 06:18 AM.

          Comment


          • #6
            I'm guessing you left the "This sample eSignal...." lines in as you show them below.

            Those are comments and you need to put // in front of them so they show as grey lines in the efs editor.

            efs is thinking they are code lines and trying to figure out what they mean

            You could also just delete the 2 lines.

            Comment


            • #7
              Hard to do

              I tryed lots of solutions, but no results.
              I need more help, please!

              Comment


              • #8
                can you put the efs file here as an attachment so I can download it and see what it does on my machine?

                Comment


                • #9
                  Try the attached file. It works for me.
                  Attached Files

                  Comment


                  • #10
                    Good work

                    Hi, Smeyer55,
                    Good work. I will study it to learn how to do it.
                    Thank you very much.

                    Comment

                    Working...
                    X