Announcement

Collapse
No announcement yet.

Bollinger Bands and Excel DDE

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

  • Bollinger Bands and Excel DDE

    I've been trying all weekend to produce and EFS study with the Bollinger Bands in order to use it as a DDEOutput into Excel. I've been able to successfully do this for RSI and MACD, but can't seem to get it right for the Bollinger Bands to work. I basically just want to be able to write this EFS so by DDE it sends the values for the Upper, Basis and Lower bands into Excel. Can you help me at all with this?? Thanks!

  • #2
    jstulgis
    Post the code with the Bollinger study you have been working on and someone may be able to assist you
    Alex

    Comment


    • #3
      Thanks Alexis, I've been trying to post this response for a couple days so hopefully it works this time. I'm not sure how good or bad this code is, but if you could tweak it so that it works that would be really great. Here it is:

      PHP Code:
      var ddeUpper null;

      var 
      ddeMiddle null;

      var 
      ddeLower null;

      var 
      vBollingerStudy null;



      function 
      preMain() {
          
          
      setPriceStudy(true);
          
          
      setStudyTitle("DDE Bollinger");
          
          
      setShowCursorLabel(false);
          
      }



      function 
      main() {

          if (
      ddeUpper == null) {
              var 
      sName "UpperBollinger" getSymbol() + getInterval();
              
              
      sName sName.replace(" ","_");
              
              
      //debugPrintIn(sName);
              
              
      ddeUpper = new DDEOutput(sName);
              
              
      sName "MiddleBollinger" getSymbol() + getInterval();
              
              
      sName sName.replace(" ","_");
              
              
      //debugPrintIn(sName);
              
              
      ddeMiddle = new DDEOutput(sName);
              
              
      sName "LowerBollinger" getSymbol() + getInterval();
              
              
      sName sName.replace(" ","_");
              
              
      //debugPrintIn(sName);
              
              
      ddeLower = new DDEOutput(sName);
              
          }
          
          
          if(
      vBollingerStudy == nullvBollingerStudy = new BollingerStudy(20"Close"2.0);
          
          
          var 
      Upper study.getValue(BollingerStudy.UPPER);
          var 
      Middle study.getValue(BollingerStudy.BASIS);
          var 
      Lower study.getValue(BollingerStudy.LOWER);
          
             
          if (
      vUpper !=nullddeUpper.set(vUpper);
          if (
      vMiddle !=nullddeMiddle.set(vMiddle);
          if (
      vLower !=nullddeLower.set(vUpper);   
              
              
              return;
              
              
          } 

      Comment


      • #4
        stulgis
        There are a couple of syntax errors in the code you posted (these can also be found using the syntax checker).
        One is that you used study.getValue(BollingerStudy...) instead of vBollingerStudy(BollingerStudy...). Another is that you added a v to vUpper, vLower, etc but when you declared those variables you named them Upper, Lower, etc.
        Once you fix these errors the script should work fine
        Alex

        Comment


        • #5
          Thanks for the help, next time I'll make sure to use that syntax check before I try and run anything. When I made those changes it ran fine on Esignal, but then when I went to pull up one of the values in Excel it always gave me a value of 0 for the upper, lower and basis. I typed it into Excel like:

          =eSignal|EFS!UpperBollingerABC3

          I was using a 3 minute chart of ABC so I think that was the correc thing to type into Excel. I'll post the corrected code here for you to see, so if you can let me know if I'm doing anything wrong with Excel I'd appreciate it. thanks!

          PHP Code:
          var ddeUpper null;

          var 
          ddeMiddle null;

          var 
          ddeLower null;

          var 
          vBollingerStudy null;



          function 
          preMain() {
              
              
          setPriceStudy(true);
              
              
          setStudyTitle("DDE Bollinger");
              
              
          setShowCursorLabel(false);
              
          }



          function 
          main() {

              if (
          ddeUpper == null) {
                  var 
          sName "UpperBollinger" getSymbol() + getInterval();
                  
                  
          sName sName.replace(" ","_");
                  
                  
          //debugPrintIn(sName);
                  
                  
          ddeUpper = new DDEOutput(sName);
                  
                  
          sName "MiddleBollinger" getSymbol() + getInterval();
                  
                  
          sName sName.replace(" ","_");
                  
                  
          //debugPrintIn(sName);
                  
                  
          ddeMiddle = new DDEOutput(sName);
                  
                  
          sName "LowerBollinger" getSymbol() + getInterval();
                  
                  
          sName sName.replace(" ","_");
                  
                  
          //debugPrintIn(sName);
                  
                  
          ddeLower = new DDEOutput(sName);
                  
              }
              
              
              if(
          vBollingerStudy == nullvBollingerStudy = new BollingerStudy(20"Close"2.0);
              
              
              var 
          Upper vBollingerStudy(BollingerStudy.UPPER);
              var 
          Middle vBollingerStudy(BollingerStudy.BASIS);
              var 
          Lower vBollingerStudy(BollingerStudy.LOWER);
              
                 
              if (
          Upper !=nullddeUpper.set(vUpper);
              if (
          Middle !=nullddeMiddle.set(vMiddle);
              if (
          Lower !=nullddeLower.set(vUpper);   
                  
                  
                  return;
                  
                  
              } 

          Comment


          • #6
            jstulgis
            You are using a different variable name (ie ddeUpper.set(vUpper) than the one you declared ie var Upper
            Alex

            Comment


            • #7
              So now is the only code I need to change the part near the very end? I changed the last part so when it said:

              ddeUpper.set(vUpper) I changed it to ddeUpper(vUpper)

              Is this correct? I'll post the new code that I tried. When I ran it in Excel I still got values of zero for everything. Thanks again for your help!

              var ddeUpper = null;

              var ddeMiddle = null;

              var ddeLower = null;

              var vBollingerStudy = null;



              function preMain() {

              setPriceStudy(true);

              setStudyTitle("DDE Bollinger");

              setShowCursorLabel(false);

              }



              function main() {

              if (ddeUpper == null) {
              var sName = "UpperBollinger" + getSymbol() + getInterval();

              sName = sName.replace(" ","_");

              //debugPrintIn(sName);

              ddeUpper = new DDEOutput(sName);

              sName = "MiddleBollinger" + getSymbol() + getInterval();

              sName = sName.replace(" ","_");

              //debugPrintIn(sName);

              ddeMiddle = new DDEOutput(sName);

              sName = "LowerBollinger" + getSymbol() + getInterval();

              sName = sName.replace(" ","_");

              //debugPrintIn(sName);

              ddeLower = new DDEOutput(sName);

              }


              if(vBollingerStudy == null) vBollingerStudy = new BollingerStudy(20, "Close", 2.0);


              var Upper = vBollingerStudy(BollingerStudy.UPPER);
              var Middle = vBollingerStudy(BollingerStudy.BASIS);
              var Lower = vBollingerStudy(BollingerStudy.LOWER);


              if (Upper !=null) ddeUpper(vUpper);
              if (Middle !=null) ddeMiddle(vMiddle);
              if (Lower !=null) ddeLower(vLower);


              return;


              }

              Comment


              • #8
                jstulgis
                You only needed to change the variable name inside the brackets ie ddeUpper.set(Upper). Apply the same to the other lines that follow
                Alex

                Comment


                • #9
                  Thanks, I changed those three lines to:

                  if (Upper !=null) ddeUpper.set(Upper);
                  if (Middle !=null) ddeMiddle.set(Middle);
                  if (Lower !=null) ddeLower.set(Lower);

                  I still get the same result though with everything showing up as 0 in Excel. Here is the entire code again and thanks for the help, I've been working at this for a few days and really appreciate it.

                  PHP Code:
                  var ddeUpper null;

                  var 
                  ddeMiddle null;

                  var 
                  ddeLower null;

                  var 
                  vBollingerStudy null;



                  function 
                  preMain() {
                      
                      
                  setPriceStudy(true);
                      
                      
                  setStudyTitle("DDE Bollinger");
                      
                      
                  setShowCursorLabel(false);
                      
                  }



                  function 
                  main() {

                      if (
                  ddeUpper == null) {
                          var 
                  sName "UpperBollinger" getSymbol() + getInterval();
                          
                          
                  sName sName.replace(" ","_");
                          
                          
                  //debugPrintIn(sName);
                          
                          
                  ddeUpper = new DDEOutput(sName);
                          
                          
                  sName "MiddleBollinger" getSymbol() + getInterval();
                          
                          
                  sName sName.replace(" ","_");
                          
                          
                  //debugPrintIn(sName);
                          
                          
                  ddeMiddle = new DDEOutput(sName);
                          
                          
                  sName "LowerBollinger" getSymbol() + getInterval();
                          
                          
                  sName sName.replace(" ","_");
                          
                          
                  //debugPrintIn(sName);
                          
                          
                  ddeLower = new DDEOutput(sName);
                          
                      }
                      
                      
                      if(
                  vBollingerStudy == nullvBollingerStudy = new BollingerStudy(20"Close"2.0);
                      
                      
                      var 
                  Upper vBollingerStudy(BollingerStudy.UPPER);
                      var 
                  Middle vBollingerStudy(BollingerStudy.BASIS);
                      var 
                  Lower vBollingerStudy(BollingerStudy.LOWER);
                      
                         
                      if (
                  Upper !=nullddeUpper.set(Upper);
                      if (
                  Middle !=nullddeMiddle.set(Middle);
                      if (
                  Lower !=nullddeLower.set(Lower);   
                          
                          
                          return;
                          
                          
                      } 

                  Comment


                  • #10
                    jstulgis
                    The reason it is returning 0 is due to an error I introduced when suggesting one of the initial fixes.
                    var Upper = vBollingerStudy(BollingerStudy.UPPER); should be var Upper = vBollingerStudy.getValue(BollingerStudy.UPPER); The same applies to the two lines that follow.
                    Alex

                    Comment


                    • #11
                      Thanks Alex, that did the trick!

                      Comment


                      • #12
                        jstulgis
                        You are most welcome.
                        As an aside you could simplify the following section of your code (shown here without all the debugPrintln())

                        PHP Code:
                        if (ddeUpper == null) {
                                var 
                        sName "UpperBollinger" getSymbol() + getInterval(); 
                                
                        sName sName.replace(" ","_");
                                
                                
                        ddeUpper = new DDEOutput(sName);
                                
                                
                        sName "MiddleBollinger" getSymbol() + getInterval();
                                
                                
                        sName sName.replace(" ","_");
                                
                                
                        ddeMiddle = new DDEOutput(sName);
                                
                                
                        sName "LowerBollinger" getSymbol() + getInterval();
                                
                                
                        sName sName.replace(" ","_");
                                
                                
                        ddeLower = new DDEOutput(sName);
                                
                            } 
                        and condense it to the following

                        PHP Code:
                        if (ddeUpper == null) {
                                var 
                        sName getSymbol() + getInterval();
                                
                        sName sName.replace(" ","_");
                                
                                
                        ddeUpper  = new DDEOutput("UpperBollinger"+sName);
                                
                        ddeMiddle = new DDEOutput("MiddleBollinger"+sName);
                                
                        ddeLower  = new DDEOutput("LowerBollinger"+sName);
                            } 
                        The result will be the same
                        Alex

                        Comment

                        Working...
                        X