Announcement

Collapse
No announcement yet.

Linking data to excel

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

  • Linking data to excel

    I have been trying to link indicator data to Excel. After searching through the forums I have been able to get the moving average to work, but no success with anything else. there was a CCI example as well but didnt work for some reason.
    Im looking for a basic template that I can just add the indicators I want to.
    Any help would be greatly appreciated.

  • #2
    Bollinger example

    I tried to write an EFS for Bollinger bands using the moving average example. This is what I cam e up with, but came up with an error when I tried to use it

    var study = new BollingerStudy(20, "Close", 2.0);

    var dde = new DDEOutput("Bollinger" + getSymbol());



    function preMain() {

    setPriceStudy(true);

    }



    function main() {

    var vRet = study.getValue(BollingerStudy.Bollinger);

    if(vRet != null) dde.set(vRet);

    return vRet;

    }


    it came back with an error saying parameter no. 1 is invalid and cant convert BollingerStudy.bollinger to an integer....

    Comment


    • #3
      Hello maninjapan,

      It looks like the problem is that you are not specifying a valid barType. In your code you specify BollingerStudy.Bollinger. That is not a valid argument. Please use one of the following values instead:
      • BollingerStudy.BASIS
      • BollingerStudy.LOWER
      • BollingerStudy.UPPER

      Try that and let us know if you get the results you are after.

      AveryH
      eSignal Support

      Comment


      • #4
        Ok, this is what I got and it worked ok, now can I add the LOWER to the same EFS? if so where do I add it?


        var study = new BollingerStudy(20, "Close", 2.0);

        var dde = new DDEOutput("Bollinger" + getSymbol());



        function preMain() {

        setPriceStudy(true);

        }



        function main() {

        var vRet = study.getValue(BollingerStudy.UPPER);

        if(vRet != null) dde.set(vRet);

        return vRet;



        }

        Comment


        • #5
          maninjapan
          You can add as many DDE outputs as you want/need. For an example of an efs with multiple DDE outputs see this thread
          Also try searching the forum and you should find other examples
          Alex


          Originally posted by maninjapan
          Ok, this is what I got and it worked ok, now can I add the LOWER to the same EFS? if so where do I add it?


          var study = new BollingerStudy(20, "Close", 2.0);

          var dde = new DDEOutput("Bollinger" + getSymbol());



          function preMain() {

          setPriceStudy(true);

          }



          function main() {

          var vRet = study.getValue(BollingerStudy.UPPER);

          if(vRet != null) dde.set(vRet);

          return vRet;



          }

          Comment


          • #6
            Thanks, Ive given it a go, and it seems to verify without any syntax errors, but the indicators dont appear on the actual chart. Here is the code I tried it with . I also havent figured out how to add the extra name replace either....


            var ddebollingerbasis = null;
            var ddebollingerlower = null;
            var ddebollingerupper = null;
            var vBOL= new BollingerStudy(20, "Close", 2.0);

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

            function main() {
            if (ddebollingerbasis == null) {
            var sName = "bollingerbasis" + getSymbol() + getInterval();
            sName = sName.replace("$", ""); // remove $ from string
            sName = sName.replace("#", ""); // remove # from string
            sName = sName.replace("-","");
            sName = sName.replace(" ", "_") // replace space with underscore
            debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
            ddebollingerbasis = new DDEOutput(sName);
            }

            var vbollingerbasis = vBOL.getValue(BollingerStudy.BASIS);
            if (vBOL == null) ddebollingerbasis.set(vbollingerbasis);
            var vbollingerlower = vBOL.getValue(BollingerStudy.LOWER);
            if (vBOL == null) ddebollingerlower.set(vbollingerlower);
            var vbollingerupper = vBOL.getValue(BollingerStudy.UPPER);
            if (vBOL == null) ddebollingerupper.set(vbollingerupper);






            return;
            }

            Comment


            • #7
              maninjapan
              The indicators are not plotting in the chart because you are not returning them from the efs. Replace your current return statement ie
              return;
              with
              return new Array (vbollingerbasis, vbollingerlower, vbollingerupper);
              With regards to your other question try running a search in the forum using the keyword bollinger* dde as I believe this very same topic has been covered before
              Alex


              Originally posted by maninjapan
              Thanks, Ive given it a go, and it seems to verify without any syntax errors, but the indicators dont appear on the actual chart. Here is the code I tried it with . I also havent figured out how to add the extra name replace either....


              var ddebollingerbasis = null;
              var ddebollingerlower = null;
              var ddebollingerupper = null;
              var vBOL= new BollingerStudy(20, "Close", 2.0);

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

              function main() {
              if (ddebollingerbasis == null) {
              var sName = "bollingerbasis" + getSymbol() + getInterval();
              sName = sName.replace("$", ""); // remove $ from string
              sName = sName.replace("#", ""); // remove # from string
              sName = sName.replace("-","");
              sName = sName.replace(" ", "_") // replace space with underscore
              debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
              ddebollingerbasis = new DDEOutput(sName);
              }

              var vbollingerbasis = vBOL.getValue(BollingerStudy.BASIS);
              if (vBOL == null) ddebollingerbasis.set(vbollingerbasis);
              var vbollingerlower = vBOL.getValue(BollingerStudy.LOWER);
              if (vBOL == null) ddebollingerlower.set(vbollingerlower);
              var vbollingerupper = vBOL.getValue(BollingerStudy.UPPER);
              if (vBOL == null) ddebollingerupper.set(vbollingerupper);






              return;
              }

              Comment


              • #8
                Alexis ,thanks for your help. I made the change you suggested but once I triedto apply it to a chart, it came back with an error 'line 26 TypeError: ddebollingerlower has no properties'

                here is the code that gave the error

                var ddebollingerbasis = null;
                var ddebollingerlower = null;
                var ddebollingerupper = null;
                var vBOL= new BollingerStudy(20, "Close", 2.0);

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

                function main() {
                if (ddebollingerbasis == null) {
                var sName = "bollingerbasis" + getSymbol() + getInterval();
                sName = sName.replace("$", ""); // remove $ from string
                sName = sName.replace("#", ""); // remove # from string
                sName = sName.replace("-","");
                sName = sName.replace(" ", "_") // replace space with underscore
                debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
                ddebollingerbasis = new DDEOutput(sName);
                }

                var vbollingerbasis = vBOL.getValue(BollingerStudy.BASIS);
                if (vbollingerbasis != null) ddebollingerbasis.set(vbollingerbasis);
                var vbollingerlower = vBOL.getValue(BollingerStudy.LOWER);
                if (vbollingerlower != null) ddebollingerlower.set(vbollingerlower);
                var vbollingerupper = vBOL.getValue(BollingerStudy.UPPER);
                if (vbollingerupper != null) ddebollingerupper.set(vbollingerupper);

                return new Array (vbollingerbasis, vbollingerlower, vbollingerupper);
                }

                Comment


                • #9
                  maninjapan
                  FYI that error is unrelated to the change you made and is due instead to the following lines of code
                  if (vbollingerlower != null) ddebollingerlower.set(vbollingerlower);
                  if (vbollingerupper != null) ddebollingerupper.set(vbollingerupper);

                  in which you are making references to DDE objects that have not been initialized.
                  To resolve this you need to initialize the objects in the same way you did for ddebollingerbasis eg
                  ddebollingerupper = new DDEOutput("your_var_name1"+sName);
                  ddebollingerlower = new DDEOutput("your_var_name2"+sName);

                  To see additional examples on this same topic try running a search in the forum using the keyword bollinger* dde as I suggested earlier
                  Alex


                  Originally posted by maninjapan
                  Alexis ,thanks for your help. I made the change you suggested but once I triedto apply it to a chart, it came back with an error 'line 26 TypeError: ddebollingerlower has no properties'

                  here is the code that gave the error

                  var ddebollingerbasis = null;
                  var ddebollingerlower = null;
                  var ddebollingerupper = null;
                  var vBOL= new BollingerStudy(20, "Close", 2.0);

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

                  function main() {
                  if (ddebollingerbasis == null) {
                  var sName = "bollingerbasis" + getSymbol() + getInterval();
                  sName = sName.replace("$", ""); // remove $ from string
                  sName = sName.replace("#", ""); // remove # from string
                  sName = sName.replace("-","");
                  sName = sName.replace(" ", "_") // replace space with underscore
                  debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
                  ddebollingerbasis = new DDEOutput(sName);
                  }

                  var vbollingerbasis = vBOL.getValue(BollingerStudy.BASIS);
                  if (vbollingerbasis != null) ddebollingerbasis.set(vbollingerbasis);
                  var vbollingerlower = vBOL.getValue(BollingerStudy.LOWER);
                  if (vbollingerlower != null) ddebollingerlower.set(vbollingerlower);
                  var vbollingerupper = vBOL.getValue(BollingerStudy.UPPER);
                  if (vbollingerupper != null) ddebollingerupper.set(vbollingerupper);

                  return new Array (vbollingerbasis, vbollingerlower, vbollingerupper);
                  }

                  Comment


                  • #10
                    Alexis, thanks a lot for your help. It seems to be working fine now. I also think I figured out the 'replace' part too.

                    var ddebollingerbasis = null;
                    var ddebollingerlower = null;
                    var ddebollingerupper = null;
                    var vBOL= new BollingerStudy(20, "Close", 2.0);

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

                    function main() {
                    if (ddebollingerbasis == null) {
                    var sName = "bollingerbasis" + getSymbol() + getInterval();
                    sName = sName.replace("$", ""); // remove $ from string
                    sName = sName.replace("#", ""); // remove # from string
                    sName = sName.replace("-","");
                    sName = sName.replace(" ", "_") // replace space with underscore
                    debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
                    ddebollingerbasis = new DDEOutput(sName);


                    }
                    if (ddebollingerupper == null) {
                    var sName = "bollingerupper" + getSymbol() + getInterval();
                    sName = sName.replace("$", ""); // remove $ from string
                    sName = sName.replace("#", ""); // remove # from string
                    sName = sName.replace("-","");
                    sName = sName.replace(" ", "_") // replace space with underscore
                    debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);

                    ddebollingerupper = new DDEOutput(sName);

                    }
                    if (ddebollingerlower == null) {
                    var sName = "bollingerlower" + getSymbol() + getInterval();
                    sName = sName.replace("$", ""); // remove $ from string
                    sName = sName.replace("#", ""); // remove # from string
                    sName = sName.replace("-","");
                    sName = sName.replace(" ", "_") // replace space with underscore
                    debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);

                    ddebollingerlower = new DDEOutput(sName);
                    }

                    var vbollingerbasis = vBOL.getValue(BollingerStudy.BASIS);
                    if (vbollingerbasis != null) ddebollingerbasis.set(vbollingerbasis);
                    var vbollingerlower = vBOL.getValue(BollingerStudy.LOWER);
                    if (vbollingerlower != null) ddebollingerlower.set(vbollingerlower);
                    var vbollingerupper = vBOL.getValue(BollingerStudy.UPPER);
                    if (vbollingerupper != null) ddebollingerupper.set(vbollingerupper);

                    return new Array (vbollingerbasis, vbollingerlower, vbollingerupper);
                    }

                    Comment


                    • #11
                      mainjapan
                      You are most welcome and I am glad to hear that it is working now
                      Alex


                      Originally posted by maninjapan
                      Alexis, thanks a lot for your help. It seems to be working fine now. I also think I figured out the 'replace' part too.

                      var ddebollingerbasis = null;
                      var ddebollingerlower = null;
                      var ddebollingerupper = null;
                      var vBOL= new BollingerStudy(20, "Close", 2.0);

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

                      function main() {
                      if (ddebollingerbasis == null) {
                      var sName = "bollingerbasis" + getSymbol() + getInterval();
                      sName = sName.replace("$", ""); // remove $ from string
                      sName = sName.replace("#", ""); // remove # from string
                      sName = sName.replace("-","");
                      sName = sName.replace(" ", "_") // replace space with underscore
                      debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);
                      ddebollingerbasis = new DDEOutput(sName);


                      }
                      if (ddebollingerupper == null) {
                      var sName = "bollingerupper" + getSymbol() + getInterval();
                      sName = sName.replace("$", ""); // remove $ from string
                      sName = sName.replace("#", ""); // remove # from string
                      sName = sName.replace("-","");
                      sName = sName.replace(" ", "_") // replace space with underscore
                      debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);

                      ddebollingerupper = new DDEOutput(sName);

                      }
                      if (ddebollingerlower == null) {
                      var sName = "bollingerlower" + getSymbol() + getInterval();
                      sName = sName.replace("$", ""); // remove $ from string
                      sName = sName.replace("#", ""); // remove # from string
                      sName = sName.replace("-","");
                      sName = sName.replace(" ", "_") // replace space with underscore
                      debugPrintln("DDE Link for Excel =eSignal|EFS!"+sName);

                      ddebollingerlower = new DDEOutput(sName);
                      }

                      var vbollingerbasis = vBOL.getValue(BollingerStudy.BASIS);
                      if (vbollingerbasis != null) ddebollingerbasis.set(vbollingerbasis);
                      var vbollingerlower = vBOL.getValue(BollingerStudy.LOWER);
                      if (vbollingerlower != null) ddebollingerlower.set(vbollingerlower);
                      var vbollingerupper = vBOL.getValue(BollingerStudy.UPPER);
                      if (vbollingerupper != null) ddebollingerupper.set(vbollingerupper);

                      return new Array (vbollingerbasis, vbollingerlower, vbollingerupper);
                      }

                      Comment

                      Working...
                      X