Announcement

Collapse
No announcement yet.

Export extant studies data via DDE

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

  • Export extant studies data via DDE

    I would like to export the existing studies (most recent) data to Excel via DDE. I have looked over the examples in this forum, I am familiar with the DDE Object, I can create (new) in the EFS, and can see how to create multiple DDE objects in the EFS. However, I have a variety of studies running on different (advanced) charts, and would prefer not to hard code a study and its parameters into the EFS because I tailor the parameters to the symbols.

    When you press Alt-E for Data Export, the last line of the data export screen is the data I'm after - only the most recent. Is that data saved internally in the chart anywhere so I can "get" it like I would "getsymbol()"? If so, I could create a generic EFS that I could add to any chart and it would return the values as (study1, study2, study3, etc), regardless of the studies and their parameters already running in the chart.

    Otherwise, I would have to run the custom study (new) in the EFS (to get its value to return) and would have to edit the EFS to change its parameters to change the chart.

    I could see creating empty study variables, then recursively going through the list of existing studies, get the name of the study, and name the DDEObject=getsymbol()+getStudyName - or even create generic study1, study2, study3, etc, which would be DDEObject=getsymbol()+"study1", and then you would have to look in the chart's Alt-E to determine which data point corresponds.

    As far as I can tell the SigTools does not return custom study values, nor does Qlink, so the only other option is EFS DDEObject for custom studies like Jurik, etc.

    I'm guessing the chart saves all of the Alt-E data in a seriesobject, but I can't find a method to "get" it. I'm sure it's just an array, and to would be very cool to be able to "getDataExportObject.value(0...n)". There are a variety of specific threads that this more generic solution would answer.

    "How do I export data into Excel" is an extremely popular request, and this more generic option that a user could add to any chart would help many others as well. I think this would make a lot of people happy since they could return DDE values easily no matter what custom studies they were already running (and changing periodically) on the chart - an alternative to hardcoding a study with different parameters into each EFS.

    Sorry for the long post, but I thought I'd explain as much as I could initially to prevent confusion.

  • #2
    To the point...

    OK, so that was TMI...

    Is there a method that I can call in an EFS to getValue of the Data Export most current values already running in the Advanced Chart? I would prefer not recreate the custom study running in the Advanced Chart in the EFS in order to get its value.

    Thanks in advance.

    Comment


    • #3
      Hello Avalon007,

      In order to access the study values in the Advanced chart and send them to Excel via DDE, you have to have a formula running in the chart that creates the DDE links that you need. The data in the Export window is the same data.

      You can create a single formula that can be applied to many charts and not have to manually change the parameters for the formula in each chart. Use the getSymbol() function in the code to determine what symbol is being processed and then set your parameter values based on the symbol string.

      PHP Code:
      var mySym getSymbol();

      if (
      mySym == "IBM") {
          
      nLength 21;
          
      // etc
      } else if (mySym == "DELL") {
          
      nLength 15;
          
      // etc.
      }

      var 
      xEMA ema(nLength); 
      Also use the symbol string from mySym above when building the DDE name for the DDE Object. This will allow you to use the same formula on many charts while creating unique DDE links for each of the symbols or charts where the formula is running.

      PHP Code:
      var study      null
      var 
      dde      null
      var 
      bInit      false

      function 
      preMain() { 

         
      setPriceStudy(true); 



      function 
      main() { 
      var 
      retVal
      var 
      mySym getSymbol();

         if ( 
      bInit==false ) { 
            var 
      nLength 10;
            if (
      mySym == "IBM") {
                
      nLength 21;
            } else if (
      mySym == "DELL") {
                
      nLength 15;
            }
            
      //create an EMA study 
            
      study emanLength ); 
            
      dde = new DDEOutput"movavg" mySym );
            
      bInit=true
         } 

         
      //gather the current value from the study 
         
      retVal study.getValue(0); 

         
      //if it is not null, assign it to our DDE object 
         
      if ( retVal != nulldde.setretVal ); 

         return( 
      retVal ); 

      If you need to create multiple DDE links within the same formula, just give them unique names concatenated with mySym as in the example above and return an array of the indicators in the return statement. You'll also need to create unique object names. In the example above "dde" is the object name for this DDE link. Create new ones such as dde1, dde2 or dde_ma, dde_stoch etc.

      See also the code example in the KB, EFS DDE Object, and this thread.
      Jason K.
      Project Manager
      eSignal - an Interactive Data company

      EFS KnowledgeBase
      JavaScript for EFS Video Series
      EFS Beginner Tutorial Series
      EFS Glossary
      Custom EFS Development Policy

      New User Orientation

      Comment


      • #4
        The question is slightly different

        Hi JasonK,

        Thank you so much for your detailed answer. I realize that the "How do you export data to Exce" has been asked a thousand times, and I have found, I believe, most of the posts.

        My question is actually different. It is, "Is there a way to getvalue() of the values in the Data Export object that already exists in the chart?"

        I suspect the answer is "No, there isn't" because I can't find methods or other EFS code examples.

        Another way to ask the question is, "do I have to run the study in the EFS in order to get its value, or can I read it from the Data Export object that already exists". Your thoughtful and detailed answer assumes that you must run the study in the EFS in order to get its value.

        I was hoping that the Data Export object is an object series that exists in the chart and I could get its header values and array values directly from the object. Instead, it appears that the Data Export object (Alt-E screen) is built on the fly internally from aggregating the series of any study running on the chart. The Alt-E is so fast, though, it it appears to be an already extant object that simply displays to the screen when you press Alt-E (rather than built on the fly).

        So... is there a Data Export Object that I can query to get its header and data series values, or do I have to create/run (new) a study in the EFS to get its value?

        Sorry to be so wordy, but it's kind of a different question.

        Thanks for yor patience,
        Avalon007

        Comment


        • #5
          Please be so kind as to check my previous post before this, because a "Data Export" object would be preferable...

          Assuming that I cannot get an extant (already existing) data export object "getValue", I went ahead and hard coded an EFS.

          I left the lines where I think they should be, but commented them out where appropriate.

          This is my first EFS attempt, so my humble apologies if it's wierd, but I'm guessing it's reasonably close. While it gives no runtime errors, when I try to access it in Excel, I get the following results:

          =eSignal!EFSaapl5Close yields #Name?
          =eSignal!EFSaapl5JMA1 yields [object JurikJMAStudy]

          I would be grateful for your thoughts and suggestions...

          Thanks,
          Avalon007
          Attached Files

          Comment


          • #6
            Avalon007
            Here are some comments with regards to your script
            You need to declare the variables to which you assign the DDE Object globallly eg
            PHP Code:
            var ddeOpen null;

            function 
            main(){
                ...
                if(
            ddeOpen==nullddeOpen = new DDEOutput(mySym+"Open");
                ... 
            In your script you assign the series object ie open(), high(), etc to the variables vO, vH etc and then pass that to the DDE Object. That will however return [object series] in Excel (which is the problem you are seeing with the JMA studies - more on this follows)
            You need to either assign the value to the variables vO, vH, etc ie open(0), high(0), etc [preferable solution] or assign the series object to those variables but then pass the value when using the .set() method ie
            PHP Code:
            if(vO != nullddeOpen.set(vO.getValue(0)); 
            Once you make these changes these links should work
            As to the Jurik studies you omitted to retrieve the value from the JurikJMAStudy object in the following lines of code (lines 80, 83 and 86)
            PHP Code:
            if(vJMA1 != nullddeJMA1.set(vJMA1);
            ...
            if(
            vJMA2 != nullddeJMA2.set(vJMA1);
            ...
            if(
            vJMA3 != nullddeJMA3.set(vJMA1); 
            Replace those lines with the following
            PHP Code:
            if(vJMA1.getValue(JurikJMAStudy.JMA) != nullddeJMA1.set(vJMA1.getValue(JurikJMAStudy.JMA));
            ...
            if(
            vJMA2.getValue(JurikJMAStudy.JMA) != nullddeJMA2.set(vJMA1.getValue(JurikJMAStudy.JMA));
            ...
            if(
            vJMA3.getValue(JurikJMAStudy.JMA) != nullddeJMA3.set(vJMA1.getValue(JurikJMAStudy.JMA)); 
            and it should work. Note that as I do not have a subscription to the Jurik studies I am unable to verify this.
            Alex


            Originally posted by Avalon007
            Please be so kind as to check my previous post before this, because a "Data Export" object would be preferable...

            Assuming that I cannot get an extant (already existing) data export object "getValue", I went ahead and hard coded an EFS.

            I left the lines where I think they should be, but commented them out where appropriate.

            This is my first EFS attempt, so my humble apologies if it's wierd, but I'm guessing it's reasonably close. While it gives no runtime errors, when I try to access it in Excel, I get the following results:

            =eSignal!EFSaapl5Close yields #Name?
            =eSignal!EFSaapl5JMA1 yields [object JurikJMAStudy]

            I would be grateful for your thoughts and suggestions...

            Thanks,
            Avalon007

            Comment


            • #7
              JasonK and Alexis,

              First and foremost, thank you so much for your help! It works beautifully. I now see the coding error of my ways.

              Second, that's pretty cool stuff. I seriously love it. Yes, I see that I can do much more sexy stuff, but for the moment that's exactly what I was after and it rocks!

              Third, and my original question... yes, I understand that the study must be running in the chart... but... is the "Data Export" Alt-E an object (perhap an internal series object) that I can query? Can I get its values and header names without creating the study in the EFS? I can't find that anywhere in the docs.

              Thanks again to you both for all your help. Big Kudos.

              Thanks,
              Avalon007

              Comment


              • #8
                Avalon007
                You are most welcome and I am glad to hear it is working fine.
                With regards to your question efs does not have access to the Data Export window.
                Alex


                Originally posted by Avalon007
                JasonK and Alexis,

                First and foremost, thank you so much for your help! It works beautifully. I now see the coding error of my ways.

                Second, that's pretty cool stuff. I seriously love it. Yes, I see that I can do much more sexy stuff, but for the moment that's exactly what I was after and it rocks!

                Third, and my original question... yes, I understand that the study must be running in the chart... but... is the "Data Export" Alt-E an object (perhap an internal series object) that I can query? Can I get its values and header names without creating the study in the EFS? I can't find that anywhere in the docs.

                Thanks again to you both for all your help. Big Kudos.

                Thanks,
                Avalon007

                Comment

                Working...
                X