Announcement

Collapse
No announcement yet.

Average and lowest bandwith

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

  • Average and lowest bandwith

    hello, i use the formula Bandwith for the Bollinger band.
    But i would like to see on this indicator the lowest and the average of this graph in a period of 50 Bar chart.

    is it possible?

    thanks you


  • #2
    If you hate bad code, stop reading here...
    but it works

    var bb = new BollingerStudy(20, "Close", 2);
    var vEMA10 = new MAStudy(10, 0, bb, MAStudy.SIMPLE);

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("BBminAVG");
    setCursorLabelName("MAbb", 0);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarFgColor(Color.red, 0);
    setDefaultBarThickness(2, 0);
    setPlotType(PLOTTYPE_LINE, 0);
    }

    function main() {
    xx=bb.getValue(BollingerStudy.BASIS);
    xMin=9999999
    xSum=0;
    length=25
    for ( x=0; x<length; x++ ) {
    if ( bb.getValue(BollingerStudy.BASIS)<=xMin ) {
    xMin=bb.getValue(BollingerStudy.BASIS)
    xSum=xSum+bb.getValue(BollingerStudy.BASIS, -x)
    }
    }
    xx=xSum/length

    drawLineAbsolute(0, xx, -length, xx, PS_SOLID, 1, Color.blue, 99);
    drawLineAbsolute(0, xMin, -length, xMin, PS_SOLID, 2, Color.green, 999);
    return bb.getValue(BollingerStudy.BASIS);
    }
    Attached Files

    Comment


    • #3
      maybe its just me, but your formula show the BB bas.

      In fact, i would like to add a line to the Bandwidth formula ( who show the gap between the up and low BB) that show the lowest of the 50 last period of this bandwidth.

      Comment


      • #4
        Purineur
        To calculate the average of Bandwidth (or of any other custom variable) use the efs posted in this message. Examples on how to use the efs are contained in the script itself and are also available in some earlier posts in the same thread.
        Alex

        Comment


        • #5
          Purineur
          To calculate the highest and lowest value of any custom variable you can use the efs posted in this message.
          As with the moving average efs samples are included in the script itself and provided in other messages in that same thread
          Alex

          Comment


          • #6
            hello alexis, i downloaded << highest-lowest (non price studies).efs >> , and i tried to change the default values to apply it to the Bandwidth indicator.

            But it doesn't work, and i don't understand anything about the programming langage.

            I think i will study this langage to build my indicators in the future.

            But i will need this indicator of the lowest level of Bandwidth the next week, and i wonder if an expert of the efs langage could build me this indicator since it looks like a simple and quick thing to do for someone who know the langage ( it's just a line that show the lowest level of bandwith during the last 150 period).

            i would be very glad if anyone could help the meganewbie that i am to build this indicator.

            thanks you

            Comment


            • #7
              i just saw the eSignal Formula Script Central board.

              I will try to find an equivalent indicator here

              Comment


              • #8
                This efs plots the difference between the hi/lo BB band and draws a line a the loest value of thelast 50.

                var bb = new BollingerStudy(20, "Close", 2);

                function preMain() {
                setPriceStudy(false);
                setStudyTitle("BBminAVG");
                setCursorLabelName("MAbb", 0);
                setDefaultBarStyle(PS_SOLID, 0);
                setDefaultBarFgColor(Color.red, 0);
                setDefaultBarThickness(2, 0);
                setPlotType(PLOTTYPE_LINE, 0);
                }
                var xMin;
                function main() {
                xMin=9999999;
                length=50;
                for ( x=0; x<length; x++ ) {
                bbDiff=bb.getValue(BollingerStudy.UPPER,-x)-bb.getValue(BollingerStudy.LOWER,-x)
                if ( bbDiff<=xMin ) {
                xMin=bbDiff
                }
                }
                drawLineAbsolute(0, xMin, -length, xMin, PS_SOLID, 2, Color.green, 999);
                return (bb.getValue(BollingerStudy.UPPER)-bb.getValue(BollingerStudy.LOWER));
                }

                Comment


                • #9
                  thats exactly what i was looking for.

                  thanks a lot

                  Comment

                  Working...
                  X