Announcement

Collapse
No announcement yet.

I can't change Bollinger Piercing components

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

  • I can't change Bollinger Piercing components

    Whats up Wayne,

    Just got back in town, noticed you replied back to one of my postings from a few weeks ago.

    I didn't get a chance to thank you for posting that revised Bollinger Band script, and the one that you posted on here works even better.

    Where do you find all these BB scripts?
    There appear to be millions of variations and I'd like to sort through them.

    ** EDIT
    Actually I just looked at the second one you attached in the thread....what are the differences here? Which one do I download if I'm just looking for alerts everytime the stock pierces and closes above (or below) the 2 bands?

    Thanks.
    Last edited by spyder9000; 03-11-2009, 02:06 PM.

  • #2
    Hi spyder,

    Well, I modified the customBB.efs found in the formulas folder.

    I put more options than what you requested so you could play with it to see what settings you like best. I did this so you could select to get all signals or only one signal until the alerts are reset. You can have the signal reset itself after triggering (say, it triggers by crossing the upper BB then the alarm reset only if the mid or bottom BB is breached or get all signals, depending on the menu option you select from "Reset Alert At MidBB Cross of?").

    Use this one. I modified it so all the defaults are set to what you requested.

    NOTE: if you enable Arrows; red arrows will show at the top of the chart when the bottom BB is breached and green arrows will show at the bottom of the chart if the upper BB is breached.

    The number of Arrows, Sound Alerts, or Text Alerts will vary depending on which option you select under the menu item "Reset Alert At MidBB Cross of?", of course selecting option "None" will give you all the signals you enable.

    wayne
    Attached Files
    Last edited by waynecd; 03-11-2009, 06:03 PM.

    Comment


    • #3
      Whats up Wayne,

      I just downloaded your latest one, and I must say you did a phenomenal job putting this one together, I think this should be in the EFS library.

      Questions I have for you:

      Is it possible for me to throw in an extra line of code that allows me to filter it so that the alerts are only sent if the security pierces AND closes above (or below) the bands?
      Right now the alerts are sent if they are pierced, but not necessarily closed above or below.
      I couldn't figure out if I should put it somewhere between lines 130 - 158, or if you have to declare it at the beginning of the code.

      I have to wait for the market to open before I can use the text alerts.
      If I change it to TRUE, where do I type in what I want the text alert to say?

      Lastly, could you help me combine stochastics into this EFS?
      I already found the code for it, just need your assistance on what line to insert it, here is the link to the code: http://forum.esignalcentral.com/show...rossover+alert

      Once we put this thing together, I'm going to share my trading strategy with the Members of this thread so they can all try out this EFS and see if it's successful.

      Thanks!

      Comment


      • #4
        Hi,

        In this version the menu option "Alert On?" allows you to select for alerts on close above upperBB and below lowerBB, or high crossing upperBB and low crossing lowerBB.

        The default is set to "Close".

        wayne
        Attached Files

        Comment


        • #5
          Thanks, I'll check it out.

          Comment


          • #6
            Hi Spider,

            Just change the text like -"Price above upper Bollinger Band" - found in lines 150,155,162, and 167. Remembe to keep it within quotation marks.
            If I change it to TRUE, where do I type in what I want the text alert to say?
            About the Stochastics, what exactly are you looking for?

            The referenced study alarms when %k crossed the upper or lower band so this will add more alerts to the same efs and can get confusing. So, are you looking for an alarm when both cross the upper/lower band at the same time or possibly one after the other?

            Or do you just want different arrows on the chart that show when each (BB or %K) triggers?



            wayne
            Last edited by waynecd; 03-12-2009, 10:33 AM.

            Comment


            • #7
              Whats up Wayne,

              I can see this thread is getting a lot of views...I think we're doing a great job trying to master these Bollinger Bands!!

              Got a chance to play around with the latest version of this EFS, works pretty good.
              For all you people out there who downloaded it, you need to put this code into line 17:

              setComputeOnClose(true);

              This is so that you don't get the alerts going off on every single tick, it waits for the candle to finish forming (in my case I'm using 5 min charts) and then only evaluates if the condition is true or not.

              I also made some tweaks within the code that suits my own strategies, which I will post on here later.

              Wayne, regarding my stochastics question, I was wondering how to code in the "AND" function.

              Meaning that "IF" stock pierces and closes above Upper BB (or pierces and closes below Lower BB) "AND" %K is over 80 (or below 20)....then issue the audio and text alert.

              I have no idea which part of the earlier link I would copy and paste....but I imagine it would go between lines 149 and 170?

              Thanks.

              Comment


              • #8
                Hi Spider,

                I cleaned up the BB script and corrected the multiple alerts.

                Note: I assume you meant "IF Price pierces and closes above Upper BB (or pierces..." since stochastics is not related to price bollinger bands.

                Meaning that "IF" stock pierces and closes above Upper BB (or pierces and closes below Lower BB) "AND" %K is over 80 (or below 20)....then issue the audio and text alert.
                wayne
                Attached Files
                Last edited by waynecd; 03-13-2009, 04:50 AM.

                Comment


                • #9
                  Whats up Wayne,

                  Hope you had a pleasant weekend!

                  I don't see any reference to %K in this EFS?

                  I apologize if you misunderstood me before....since we've already created a really good BB alert for this thread, I wanted to move on to create a more advanced one.

                  I know that stochastics and BB aren't related.

                  What I wanted to do is combine the BB script that you created with a stochastic alert that I sent you the link for in my post before....thereby creating two indicators in the same EFS.

                  ** EXAMPLE

                  So "IF" the BB pierces and closes above the upper band "AND" the %K stochastics is over 80 "THEN" issue the audio and text alert.

                  Here is the code that I've found:

                  /************************************************** *******
                  Alexis C. Montenegro © July 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 vStoch = null;
                  var nLastRawTime;

                  function preMain() {
                  setStudyTitle("Stochastic");
                  setCursorLabelName("%K", 0);
                  setCursorLabelName("%D", 1);
                  setDefaultBarStyle(PS_SOLID, 0);
                  setDefaultBarStyle(PS_SOLID, 1);
                  setDefaultBarFgColor(Color.blue, 0);
                  setDefaultBarFgColor(Color.red, 1);
                  setDefaultBarThickness(1, 0);
                  setDefaultBarThickness(1, 1);
                  setPlotType(PLOTTYPE_LINE, 0);
                  setPlotType(PLOTTYPE_LINE, 1);

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

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

                  var fp3 = new FunctionParameter("Slow", FunctionParameter.NUMBER);
                  fp3.setLowerLimit(1);
                  fp3.setDefault(3); //Edit this value to set a new default

                  var fp4 = new FunctionParameter("Upper", FunctionParameter.NUMBER);
                  fp4.setLowerLimit(0);
                  fp4.setDefault(80); //Edit this value to set a new default

                  var fp5 = new FunctionParameter("Lower", FunctionParameter.NUMBER);
                  fp5.setLowerLimit(0);
                  fp5.setDefault(20); //Edit this value to set a new default

                  }

                  function main(K,Fast,Slow,Upper,Lower) {

                  if(vStoch==null) vStoch = new StochStudy(K, Fast, Slow);
                  addBand( Upper, PS_SOLID, 1, Color.black,2);
                  addBand( Lower, PS_SOLID, 1, Color.black,3);

                  /*********************************************
                  Insert your code following this text block
                  Use vStoch.getValue(StochStudy.FAST) and
                  vStoch.getValue(StochStudy.SLOW) for your code
                  **********************************************/

                  if (getValue("rawtime",0) != nLastRawTime) {

                  if(vStoch.getValue(StochStudy.FAST,-1)<Lower&&vStoch.getValue(StochStudy.FAST)>Lower){
                  Alert.playSound("buzz.wav");
                  nLastRawTime = getValue("rawtime",0);
                  }
                  if(vStoch.getValue(StochStudy.FAST,-1)>Upper&&vStoch.getValue(StochStudy.FAST)<Upper){
                  Alert.playSound("buzz.wav");
                  nLastRawTime = getValue("rawtime",0);
                  }
                  }


                  return new Array(vStoch.getValue(StochStudy.FAST),vStoch.getV alue(StochStudy.SLOW));

                  }


                  ** The questions I have for you is:

                  1. Is the above code correct?
                  2. Where do you insert this new code into your BB Piercing EFS?
                  3. We definitely need to keep the Arrows, Audio Alerts, and Text Alerts the same.

                  Any help?

                  Comment


                  • #10
                    Hi Spider,

                    Nothing to apologize for. I just need to know what exactly you are looking for to expedite things because there are many ways to set up the alert trigger.

                    Here is a quick rendition. You will likely need to run it on small interval like 55T etc because it doesn't generate many signals. You can verify it's accuracy by running a stochastics plot in the study pane with the same parameters (to include the location of the bands) selected in the script.

                    Play with it and let me know.

                    wayne
                    Attached Files

                    Comment


                    • #11
                      hi,

                      you also wanted compute on close, here it is plus I changed the arrows to just show at the bottom (easier on the eyes).

                      wayne
                      Attached Files

                      Comment


                      • #12
                        Hi Spider,

                        Sorry, I didn't read your whole post below so I missed your questions. (my excuse, doing taxes and sent the responses out while taking a break).

                        The code in my last post alerts when price closes above/below the respective BB and stochastics is above/below the respective band as I understood your request. For example, an up arrow will show when price closes above the upper BB and fast stochastics %K is above the upper band level.

                        In the code you provided the alarm triggers when the last bar (-1) was below the upper band level and bar 0 is above it. In other words when price crosses the band.

                        Of course, the opposite applies to the lower BB and lower band for stochastics.

                        I would not even consider that I can improve on studies created by Alexis other than to update older versions into efs2 format.

                        To answer your questions:

                        1. The code works fine.
                        2. I would update it to efs2 and insert it where I did in the code of my last post.

                        ** The questions I have for you is:

                        1. Is the above code correct?
                        2. Where do you insert this new code into your BB Piercing EFS?
                        3. We definitely need to keep the Arrows, Audio Alerts, and Text Alerts the same.

                        Any help?
                        wayne
                        Last edited by waynecd; 03-17-2009, 07:34 AM.

                        Comment


                        • #13
                          Whats up Wayne,

                          I hear ya on taxes...it seems like the tax code is different every year.

                          I downloaded the "bollinger band piercing with stoch ver2.efs".......but I'm still trying to figure out why I'm not getting correct signals.
                          There were several times when the condition was true, but the alert did not go off. Other times it did.

                          I know there are several ways to trade stochastics, so let me quickly tell you the strategy:

                          1. Identifying Overbought
                          If the candle pierces and closes above the band, AND the %k is > 80....then issue the alert.

                          ** NOTE: I tried to look at the code to find out why it issued alerts on some true conditions, but no alerts on other true conditions...but no success on this.

                          Some traders look for a %K crossover of 80...but in my strategy the alert should go out regardless of crosssovers.

                          I can give you an example if you'd like.

                          Please get back to me at your convenience....and good luck with those taxes!!!

                          Comment


                          • #14
                            Alexis,

                            This is the code that we put together, but whenever the condition is met, the alert doesn't always go off.

                            This code issues an alert whenever the stock pierces AND closes above the Upper Bollinger Band...AND when %k stochastics is > 80.
                            Also alerts when the stock pierces and closes below the Lower Bollinger Band...AND when %k is < 20

                            The alert shouldn't only just alert on crossovers below 20...it should alert on every pierce, close, and value below 20.

                            Here is the code....can you help??

                            /************************************************** *******
                            By Alexis C. Montenegro for eSignal © 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.
                            ************************************************** ********/
                            //3/11/2009 added menu options and alerts & stochastics trigger
                            debugClear();
                            var aFPArray = new Array();


                            function preMain() {

                            setPriceStudy(true);
                            setStudyTitle("Bollinger Bands Piercing");
                            setShowTitleParameters( false );
                            setComputeOnClose();

                            var x=0;
                            aFPArray[x] = new FunctionParameter( "BBLength", FunctionParameter.NUMBER);
                            with( aFPArray[x++] ) {
                            setName( "BB Length" );
                            setLowerLimit( 1 );
                            addOption(10);
                            addOption(20);
                            setDefault( 20 );
                            }
                            aFPArray[x] = new FunctionParameter( "BBStdDev", FunctionParameter.NUMBER);
                            with( aFPArray[x++] ) {
                            setName( "BB Std Deviation" );
                            setLowerLimit( 0 );
                            addOption(1);
                            addOption(2);
                            setDefault( 2 );
                            }
                            aFPArray[x] = new FunctionParameter( "UpperSoundAlert", FunctionParameter.STRING);//enables sound alert on cross of upper BB
                            with( aFPArray[x++] ) {
                            setName( "Cross Upper BB Alert" );
                            addOption( "None" );
                            addOption( "beam1.wav" );
                            addOption( "beep.wav" );
                            addOption( "Blip.wav" );
                            addOption( "Boing.wav" );
                            addOption( "swoosh.wav" );
                            addOption( "Chimes.wav" );
                            addOption( "Chime Down.wav" );
                            setDefault( "None" );
                            }
                            aFPArray[x] = new FunctionParameter( "LowerSoundAlert", FunctionParameter.STRING); //enables sound alert on cross of lower BB
                            with( aFPArray[x++] ) {
                            setName( "Cross Lower BB Alert" );
                            addOption( "None" );
                            addOption( "beam1.wav" );
                            addOption( "beep.wav" );
                            addOption( "Blip.wav" );
                            addOption( "Boing.wav" );
                            addOption( "swoosh.wav" );
                            addOption( "Chimes.wav" );
                            addOption( "Chime Down.wav" );
                            setDefault( "None" );
                            }
                            aFPArray[x] = new FunctionParameter( "ResetAlert", FunctionParameter.BOOLEAN); //Resets the Alerts on price cross of middleBB
                            with( aFPArray[x++] ) {
                            setName( "Reset Alert At Midle BB" );
                            setDefault( false );
                            }
                            aFPArray[x] = new FunctionParameter("TextAlert", FunctionParameter.BOOLEAN);//enables Text Alerts
                            with(aFPArray[x++]){
                            setName( "Text Alert" );
                            setDefault( false );
                            }
                            aFPArray[x] = new FunctionParameter("DrawArrows", FunctionParameter.BOOLEAN);//enables drawing arrows
                            with(aFPArray[x++]){
                            setName( "DrawArrows" );
                            setDefault( true );
                            }
                            aFPArray[x] = new FunctionParameter("PlotBB", FunctionParameter.BOOLEAN);//enables plotting BBs
                            with(aFPArray[x++]){
                            setName( "Plot BBs" );
                            setDefault( true );
                            }
                            aFPArray[x] = new FunctionParameter( "ShowCursorLabel", FunctionParameter.BOOLEAN); //displays plot data in Cursor Window
                            with( aFPArray[x++] ) {
                            setName( "Show Cursor Label" );
                            setDefault( false );
                            }
                            aFPArray[x] = new FunctionParameter( "S1K", FunctionParameter.NUMBER);
                            with( aFPArray[x++] ) {
                            setName( "Stoch %K (Fast)" );
                            setLowerLimit( 1 );
                            setUpperLimit( 200 );
                            addOption( 5 );
                            addOption( 14 );
                            setDefault( 14 );
                            }
                            aFPArray[x] = new FunctionParameter( "S1KSmooth", FunctionParameter.NUMBER);
                            with( aFPArray[x++] ) {
                            setName( "%K Smooth");
                            setLowerLimit( 1 );
                            addOption( 1 );
                            addOption( 3 );
                            setUpperLimit( 200 );
                            setDefault( 3 );
                            }
                            aFPArray[x] = new FunctionParameter( "S1D", FunctionParameter.NUMBER);
                            with( aFPArray[x++] ) {
                            setName( "%D (slow)" );
                            setLowerLimit( 1 );
                            addOption( 3 );
                            setUpperLimit( 200 );
                            setDefault( 3 );
                            }
                            aFPArray[x] = new FunctionParameter( "vStochTopBand", FunctionParameter.NUMBER);
                            with( aFPArray[x++] ) {
                            setName( "Top Band Level" );
                            setLowerLimit(50);
                            setUpperLimit(100);
                            addOption( 70 );
                            addOption( 80 );
                            setDefault( 80 );
                            }
                            aFPArray[x] = new FunctionParameter( "vStochBottomBand", FunctionParameter.NUMBER);
                            with( aFPArray[x++] ) {
                            setName( "Bottom Band Level" );
                            setLowerLimit(1);
                            setUpperLimit(50);
                            addOption( 20 );
                            addOption( 30 );
                            setDefault( 20 );
                            }
                            }
                            var vBBU = null;
                            var vBBM = null;
                            var vBBL = null;
                            var bInit = false;
                            var vLastAlert = -1;
                            var efsIntSound = null;
                            var BarCntr = 0;
                            var vTxtUBB = "Price above upper Bollinger Band";
                            var vTxtLBB = "Price below lower Bollinger Band";
                            var vTAlt = null;
                            var vUSndAlt = null;
                            var vLSndAlt = null;
                            var vArrows = null;
                            var K_Study = null;
                            var D_Study = null;
                            var vStochPosition = 0;

                            function main(BBLength,BBStdDev,UpperSoundAlert,LowerSoundA lert,ResetAlert,TextAlert,DrawArrows,PlotBB,ShowCu rsorLabel,
                            S1K,S1KSmooth,S1D,vStochTopBand,vStochBottomBand) {

                            var vBarCount, UBBValue, MBBValue, LBBValue, UBBValue_1, MBBValue_1, LBBValue_1, vHigh, vLow, vHigh_1, vLow_1,
                            Kvar0,Dvar0;
                            vTAlt = TextAlert;
                            vArrows = DrawArrows;
                            vUSndAlt = UpperSoundAlert;
                            vLSndAlt = LowerSoundAlert;

                            if(bInit== false){
                            setShowCursorLabel( ShowCursorLabel );
                            if(PlotBB){
                            setCursorLabelName("UBB ",0);
                            setCursorLabelName("MBB ",1);
                            setCursorLabelName("LBB ",2);
                            setCursorLabelName("Alert ",3);
                            setCursorLabelName("Count ",4);
                            }else setShowCursorLabel(false);
                            vBBU = upperBB( BBLength, BBStdDev );
                            vBBU = getSeries(vBBU);
                            vBBM = middleBB( BBLength, BBStdDev );
                            vBBM = getSeries(vBBM);
                            vBBL = lowerBB( BBLength, BBStdDev );
                            vBBL = getSeries(vBBL);
                            if(K_Study == null){
                            K_Study = stochK(S1K , S1KSmooth, S1D);
                            K_Study = getSeries(K_Study)
                            }
                            /* if(D_Study == null){ //put here in case it is needed later. Currently unused.
                            D_Study = stochD(S1K , S1KSmooth, S1D);
                            D_Study = getSeries(D_Study) ;
                            }*/
                            bInit = true;
                            }

                            vBarCount = getCurrentBarCount();
                            if(getCurrentBarCount() <= BBLength) return;

                            vClose = close(0);
                            vClose_1 = close(-1);
                            UBBValue = vBBU.getValue(0)
                            MBBValue = vBBM.getValue(0)
                            LBBValue = vBBL.getValue(0)
                            UBBValue_1 = vBBU.getValue(-1)
                            MBBValue_1 = vBBM.getValue(-1)
                            LBBValue_1 = vBBL.getValue(-1)
                            Kvar0 = K_Study.getValue(0);
                            // Dvar0 = D_Study.getValue(0);//put here in case it is needed later. Currently unused.

                            if(Kvar0 > vStochTopBand) vStochPosition = 1;
                            else if(Kvar0 < vStochBottomBand) vStochPosition = 2;
                            else vStochPosition = -1;

                            if(ResetAlert){
                            if(vLastAlert == 1 && vClose <= MBBValue) vLastAlert = -1;
                            if(vLastAlert == 2 && vClose >= MBBValue) vLastAlert = -1;
                            }
                            if (vClose_1 < UBBValue_1 && vClose > UBBValue && vStochPosition == 1){
                            OnAction1();
                            }
                            if (vClose_1 > LBBValue_1 && vClose < LBBValue && vStochPosition == 2){
                            OnAction2();
                            }

                            if(PlotBB) return new Array (UBBValue, MBBValue, LBBValue, vLastAlert.toFixed(), vBarCount.toFixed());
                            else return null;
                            }
                            function OnAction1(){
                            if (vLastAlert != 1){
                            if(vTAlt) Alert.addToList(getSymbol(), vTxtUBB, Color.RGB(0,0,0), Color.RGB(195,0,0));
                            if(vUSndAlt != "None") Alert.playSound(vUSndAlt);
                            if(vArrows) drawShape(Shape.UPARROW, BottomRow2 , Color.green);
                            vLastAlert = 1;
                            }
                            }
                            function OnAction2(){
                            if (vLastAlert != 2){
                            if(vTAlt) Alert.addToList(getSymbol(), vTxtLBB, Color.RGB(0,0,0), Color.RGB(195,0,0));
                            if(vLSndAlt != "None") Alert.playSound(vLSndAlt);
                            if(vArrows) drawShape(Shape.DOWNARROW, BottomRow2, Color.red);
                            // if(vArrows) drawShape(Shape.DOWNARROW, TopRow1, Color.red);
                            vLastAlert = 2;
                            }
                            }

                            Comment


                            • #15
                              Hi Spider,

                              but I'm still trying to figure out why I'm not getting correct signals.
                              There were several times when the condition was true, but the alert did not go off. Other times it did.
                              First make sure that the stochastics plotted in the study pane is set to 14,3,3 as are the stochastic values in the BB study (or at the very least make sure both have the same values whatever you may choose). I used 14,3,3 stochastics because those are the values in the efs you first referenced in one of your first posts.

                              The reason is found at the following lines:
                              PHP Code:
                              if (vClose_1 UBBValue_1 && vClose UBBValue && vStochPosition == 1){
                                          
                              OnAction1();
                                  }
                              if (
                              vClose_1 LBBValue_1 && vClose LBBValue && vStochPosition == 2){
                                          
                              OnAction2();
                                  } 
                              As an example: for oversold the above signals only when the previous bar (-1) closed above the lower BB and the current bar (0) closed below the BB. So if bar (-1) closes below the BB but stochastics is above the lower band (of value say, 20) there is no alarm, then the next bar also closes below the lower BB and stochastics is now below the lower band it still won't trigger because the previous bar closed below the lower BB instead of above it.

                              To change these parameters delete the conditions that call for the previous bar to close above the lower BB for oversold (the opposite for overbought) as I did in the attached study.

                              I also added a menu option to color the background for each signal and defaulted it to true, just to help see the signals better. You could of course set both up & down background colors to light grey if you prefer a neutral color for both.

                              wayne
                              Attached Files
                              Last edited by waynecd; 03-19-2009, 01:38 AM.

                              Comment

                              Working...
                              X