Announcement

Collapse
No announcement yet.

sr_bands or S/R Bands EFS

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

  • sr_bands or S/R Bands EFS

    I wonder what happended to your efs that was on esignal a while back called sr_bands

    I have wanted to download that again on another computer and use it in my application...

    Also.. I wanted to change the color of the bars... the Lime bar to a black bar and the red bar to a blue bar.... what do I need to change in the code at the end to do that..

    thank you...


  • #2
    Here is the code Ihave from sr_bands or S/R Bands

    Just wondering what I need to change to get black bar instead of lime bar and blue bar instead of red bar... thanks
    S



    /************************************************** *******
    Alexis C. Montenegro © December 2004
    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 fpArray = new Array();

    function preMain() {

    setPriceStudy(true);
    setStudyTitle("S/R Bands");
    setDefaultBarFgColor(Color.lightgrey,0);
    setDefaultBarFgColor(Color.lightgrey,1);
    setDefaultBarFgColor(Color.lightgrey,2);
    setDefaultBarFgColor(Color.lightgrey,3);
    setDefaultBarFgColor(Color.black,4);
    setDefaultBarFgColor(Color.lightgrey,5);
    setDefaultBarFgColor(Color.lightgrey,6);
    setDefaultBarFgColor(Color.lightgrey,7);
    setDefaultBarFgColor(Color.lightgrey,8);
    setDefaultBarThickness(1,0);
    setDefaultBarThickness(1,1);
    setDefaultBarThickness(1,2);
    setDefaultBarThickness(1,3);
    setDefaultBarThickness(1,4);
    setDefaultBarThickness(1,5);
    setDefaultBarThickness(1,6);
    setDefaultBarThickness(1,7);
    setDefaultBarThickness(1,8);
    setPlotType(PLOTTYPE_FLATLINES,0);
    setPlotType(PLOTTYPE_FLATLINES,1);
    setPlotType(PLOTTYPE_FLATLINES,2);
    setPlotType(PLOTTYPE_FLATLINES,3);
    setPlotType(PLOTTYPE_FLATLINES,4);
    setPlotType(PLOTTYPE_FLATLINES,5);
    setPlotType(PLOTTYPE_FLATLINES,6);
    setPlotType(PLOTTYPE_FLATLINES,7);
    setPlotType(PLOTTYPE_FLATLINES,8);

    var x=0;
    fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
    with(fpArray[x++]){
    setDefault();
    }
    fpArray[x] = new FunctionParameter("SR1", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setDefault(0.500);
    }
    fpArray[x] = new FunctionParameter("SR2", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setDefault(0.618);
    }
    fpArray[x] = new FunctionParameter("SR3", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setDefault(1.000);
    }
    fpArray[x] = new FunctionParameter("SR4", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setDefault(1.382);
    }
    fpArray[x] = new FunctionParameter("Colors", FunctionParameter.STRING);
    with(fpArray[x++]){
    addOption("ON");
    addOption("OFF");
    setDefault("ON");
    }
    fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
    with(fpArray[x++]){
    setName("Show Parameters");
    setDefault(false);
    }
    }

    var xHigh = null;
    var xLow = null;
    var xClose = null;
    var High_1 = null;
    var Low_1 = null;
    var Close_1 = null;
    var Rng = null;
    var vBal = null;
    var vUp1 = null;
    var vUp2 = null;
    var vUp3 = null;
    var vUp4 = null;
    var vDn1 = null;
    var vDn2 = null;
    var vDn3 = null;
    var vDn4 = null;
    var vInterval = null;
    var bInit = false;

    function main(Interval,SR1,SR2,SR3,SR4,Colors,Params) {

    if(bInit == false){
    if(isIntraday() && Interval == null) Interval = "D";
    else if(isDaily() && Interval == null) Interval = "W";
    else if(isWeekly() && Interval == null) Interval = "M";
    else if(Interval == null) Interval = getInterval();
    vInterval = Interval;
    xHigh = high(inv(vInterval));
    xLow = low(inv(vInterval));
    xClose = close(inv(vInterval));
    setCursorLabelName(SR4+" ", 0);
    setCursorLabelName(SR3+" ", 1);
    setCursorLabelName(SR2+" ", 2);
    setCursorLabelName(SR1+" ", 3);
    setCursorLabelName("Bal"+" ", 4);
    setCursorLabelName(SR1+" ", 5);
    setCursorLabelName(SR2+" ", 6);
    setCursorLabelName(SR3+" ", 7);
    setCursorLabelName(SR4+" ", 8);
    setShowTitleParameters(eval(Params));
    bInit = true;
    }

    if(getBarStateInterval(vInterval+"")==BARSTATE_NEW BAR){
    High_1 = xHigh.getValue(-1);
    Low_1 = xLow.getValue(-1);
    Close_1 = xClose.getValue(-1);
    Rng = High_1-Low_1;
    vBal = (High_1+Low_1+Close_1)/3;
    vUp1 = vBal+(Rng*SR1);
    vUp2 = vBal+(Rng*SR2);
    vUp3 = vBal+(Rng*SR3);
    vUp4 = vBal+(Rng*SR4);
    vDn1 = vBal-(Rng*SR1);
    vDn2 = vBal-(Rng*SR2);
    vDn3 = vBal-(Rng*SR3);
    vDn4 = vBal-(Rng*SR4);
    }
    if(High_1==null||Low_1==null||Close_1==null) return;

    if(Colors=="ON"){
    setBarBgColor(Color.lime,3,vUp1,vUp2);
    setBarBgColor(Color.yellow,1,vUp3,vUp4);
    setBarBgColor(Color.red,5,vDn2,vDn1);
    setBarBgColor(Color.yellow,7,vDn4,vDn3);
    }

    return new Array(vUp4,vUp3,vUp2,vUp1,vBal,vDn1,vDn2,vDn3,vDn4 );
    }

    Comment


    • #3
      Re: Here is the code Ihave from sr_bands or S/R Bands

      Simbu
      The script does not color the price bars.
      Alex


      Originally posted by Simbu
      Just wondering what I need to change to get black bar instead of lime bar and blue bar instead of red bar... thanks
      S



      /************************************************** *******
      Alexis C. Montenegro © December 2004
      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 fpArray = new Array();

      function preMain() {

      setPriceStudy(true);
      setStudyTitle("S/R Bands");
      setDefaultBarFgColor(Color.lightgrey,0);
      setDefaultBarFgColor(Color.lightgrey,1);
      setDefaultBarFgColor(Color.lightgrey,2);
      setDefaultBarFgColor(Color.lightgrey,3);
      setDefaultBarFgColor(Color.black,4);
      setDefaultBarFgColor(Color.lightgrey,5);
      setDefaultBarFgColor(Color.lightgrey,6);
      setDefaultBarFgColor(Color.lightgrey,7);
      setDefaultBarFgColor(Color.lightgrey,8);
      setDefaultBarThickness(1,0);
      setDefaultBarThickness(1,1);
      setDefaultBarThickness(1,2);
      setDefaultBarThickness(1,3);
      setDefaultBarThickness(1,4);
      setDefaultBarThickness(1,5);
      setDefaultBarThickness(1,6);
      setDefaultBarThickness(1,7);
      setDefaultBarThickness(1,8);
      setPlotType(PLOTTYPE_FLATLINES,0);
      setPlotType(PLOTTYPE_FLATLINES,1);
      setPlotType(PLOTTYPE_FLATLINES,2);
      setPlotType(PLOTTYPE_FLATLINES,3);
      setPlotType(PLOTTYPE_FLATLINES,4);
      setPlotType(PLOTTYPE_FLATLINES,5);
      setPlotType(PLOTTYPE_FLATLINES,6);
      setPlotType(PLOTTYPE_FLATLINES,7);
      setPlotType(PLOTTYPE_FLATLINES,8);

      var x=0;
      fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
      with(fpArray[x++]){
      setDefault();
      }
      fpArray[x] = new FunctionParameter("SR1", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setDefault(0.500);
      }
      fpArray[x] = new FunctionParameter("SR2", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setDefault(0.618);
      }
      fpArray[x] = new FunctionParameter("SR3", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setDefault(1.000);
      }
      fpArray[x] = new FunctionParameter("SR4", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setDefault(1.382);
      }
      fpArray[x] = new FunctionParameter("Colors", FunctionParameter.STRING);
      with(fpArray[x++]){
      addOption("ON");
      addOption("OFF");
      setDefault("ON");
      }
      fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
      with(fpArray[x++]){
      setName("Show Parameters");
      setDefault(false);
      }
      }

      var xHigh = null;
      var xLow = null;
      var xClose = null;
      var High_1 = null;
      var Low_1 = null;
      var Close_1 = null;
      var Rng = null;
      var vBal = null;
      var vUp1 = null;
      var vUp2 = null;
      var vUp3 = null;
      var vUp4 = null;
      var vDn1 = null;
      var vDn2 = null;
      var vDn3 = null;
      var vDn4 = null;
      var vInterval = null;
      var bInit = false;

      function main(Interval,SR1,SR2,SR3,SR4,Colors,Params) {

      if(bInit == false){
      if(isIntraday() && Interval == null) Interval = "D";
      else if(isDaily() && Interval == null) Interval = "W";
      else if(isWeekly() && Interval == null) Interval = "M";
      else if(Interval == null) Interval = getInterval();
      vInterval = Interval;
      xHigh = high(inv(vInterval));
      xLow = low(inv(vInterval));
      xClose = close(inv(vInterval));
      setCursorLabelName(SR4+" ", 0);
      setCursorLabelName(SR3+" ", 1);
      setCursorLabelName(SR2+" ", 2);
      setCursorLabelName(SR1+" ", 3);
      setCursorLabelName("Bal"+" ", 4);
      setCursorLabelName(SR1+" ", 5);
      setCursorLabelName(SR2+" ", 6);
      setCursorLabelName(SR3+" ", 7);
      setCursorLabelName(SR4+" ", 8);
      setShowTitleParameters(eval(Params));
      bInit = true;
      }

      if(getBarStateInterval(vInterval+"")==BARSTATE_NEW BAR){
      High_1 = xHigh.getValue(-1);
      Low_1 = xLow.getValue(-1);
      Close_1 = xClose.getValue(-1);
      Rng = High_1-Low_1;
      vBal = (High_1+Low_1+Close_1)/3;
      vUp1 = vBal+(Rng*SR1);
      vUp2 = vBal+(Rng*SR2);
      vUp3 = vBal+(Rng*SR3);
      vUp4 = vBal+(Rng*SR4);
      vDn1 = vBal-(Rng*SR1);
      vDn2 = vBal-(Rng*SR2);
      vDn3 = vBal-(Rng*SR3);
      vDn4 = vBal-(Rng*SR4);
      }
      if(High_1==null||Low_1==null||Close_1==null) return;

      if(Colors=="ON"){
      setBarBgColor(Color.lime,3,vUp1,vUp2);
      setBarBgColor(Color.yellow,1,vUp3,vUp4);
      setBarBgColor(Color.red,5,vDn2,vDn1);
      setBarBgColor(Color.yellow,7,vDn4,vDn3);
      }

      return new Array(vUp4,vUp3,vUp2,vUp1,vBal,vDn1,vDn2,vDn3,vDn4 );
      }

      Comment


      • #4
        sorry not price bar..

        not the price bar...sorry for my ignorance in trying to figure this out..

        but at the bottom of the code that is listed... there is code for

        if(Colors=="ON"){
        setBarBgColor(Color.lime,3,vUp1,vUp2);
        setBarBgColor(Color.yellow,1,vUp3,vUp4);
        setBarBgColor(Color.red,5,vDn2,vDn1);
        setBarBgColor(Color.yellow,7,vDn4,vDn3);
        }


        I want to change the lime to black and the red to blue... I tried typing in those colors ..like black for lime and blue for red... but nothing changed... what else needs to change or do to make those changes and thank you..
        S

        Comment


        • #5
          Re: sorry not price bar..

          Simbu
          Those instructions paint the background. To change the colors just replace the name of the color currently set in the script with one of the available colors. Then save the script and reload the efs.
          For the complete list (and syntax) of available color names see this article in the EFS KnowledgeBase
          Alex


          Originally posted by Simbu
          not the price bar...sorry for my ignorance in trying to figure this out..

          but at the bottom of the code that is listed... there is code for

          if(Colors=="ON"){
          setBarBgColor(Color.lime,3,vUp1,vUp2);
          setBarBgColor(Color.yellow,1,vUp3,vUp4);
          setBarBgColor(Color.red,5,vDn2,vDn1);
          setBarBgColor(Color.yellow,7,vDn4,vDn3);
          }


          I want to change the lime to black and the red to blue... I tried typing in those colors ..like black for lime and blue for red... but nothing changed... what else needs to change or do to make those changes and thank you..
          S

          Comment


          • #6
            i figured it out

            I figured it out... thanks..

            have a good day!

            Comment

            Working...
            X