Announcement

Collapse
No announcement yet.

combine multiple DDE outputs, and studies, to 1 file

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

  • combine multiple DDE outputs, and studies, to 1 file

    Hi. Does anyone have some time to combine the following three basic studies and their DDE outputs into one efs file, or provide direction?

    My goal is to have two moving averages and one RSI combined into one file, producing three separate DDE outputs each for a different cell in Excel.

    The idea is to save CPU usage, and limit the number of files in a chart, as I am using 10 stocks, so 10 charts.

    I read this page stating a DDEOutput Object can be created for each indicator, in one file, but can't figure out the string identifier, or how to combine the studies to one file to begin with. It seems straightforward, but I am still working on it.

    Attached is the code that I am trying to combine and produce three DDE outputs from:

    Thank you for your time and direction.
    Attached Files
    Last edited by retrac; 01-16-2016, 12:10 PM.

  • #2
    r

    To consolidate these 3 studies:

    1- Rename all variables so there are no duplicates
    2- Since these are simple scripts, set up the primary efs then add the lines of code for the other two efs scripts under the equivalent code in the primary efs.
    3- If a plot (in the return statement) has a different scale than where it will plot on the chart it will screw up the chart scale so it is best to make the output text since your intent is to export via DDE (RSI scale is 0 to 100). Otherwise it is best to not consolidate it and instead load it as a separate efs.

    The following efs plots fine in a chart but note that I have not tested the output since it DDE outputs in real time & it is Sunday. I'll leave the DDE test to you.

    Just insert the prefix
    =eSignal|EFS!
    into the desired MS Excel spreadsheet cell and add the stock symbol at the end (=eSignal|EFS!IBM). That should plot when the markets are open.

    PHP Code:
    var study_ema1      null
    var 
    dde_ema1      = new DDEOutput"ma21ec" getSymbol() ); 
    var 
    study_ema2      null
    var 
    dde_ema2      = new DDEOutput"ma8ec" getSymbol() ); 
    var 
    study_rsi      null
    var 
    dde_rsi      = new DDEOutput"RSIc" getSymbol() ); 
    var 
    bInit      false
    function 
    preMain() { 
       
    setPriceStudy(true); 

    function 
    main() { 
     var 
    retVal_ema1=null
     var 
    retVal_ema2=null
     var 
    retVal_rsi=null
       if ( 
    bInit==false ) { 
          
    //EMA study 
          
    study_ema1 ema21 ); 
          
    study_ema2 ema); 
          
    study_rsi rsi(14);
          
    bInit=true
       } 
        
    retVal_ema1 study_ema1.getValue(0); 
        
    retVal_ema2 study_ema2.getValue(0); 
        
    retVal_rsi study_rsi.getValue(0); 
       
    //assign it to DDE object 
       
    if ( retVal_ema1 != nulldde_ema1.setretVal_ema1 ); 
       if ( 
    retVal_ema2 != nulldde_ema2.setretVal_ema2 ); 
       if ( 
    retVal_rsi != nulldde_rsi.setretVal_rsi ); 
       return new Array( 
    retVal_ema1,retVal_ema2,retVal_rsi+"" ); //RSI plots in a different scale so it is best to make it text so it doesn't screw up the price pane plot.  Add a separate RSI study to the chart if you want it plotted.

    Wayne
    Last edited by waynecd; 01-17-2016, 02:31 AM.

    Comment


    • #3
      Wayne, this is a big help and thanks for sending the code. I have it loaded, it's correct in the chart and excel, and I will test DDE when the market opens.

      Thanks for the heads up on the the plot scale and making the output text for the RSI. Is that what the +"" is after retVal_rsi in the return statement? I added a sub chart for RSI and it plots as it should.

      For reference, I included prior bar outputs for moving averages, and that is working in the code you sent also. Thanks - Carter

      Comment


      • #4
        Carter
        FWIW you do not need for the market to be open to test the DDE output as you can use Bar Replay
        Alex


        Originally posted by retrac View Post
        Wayne, this is a big help and thanks for sending the code. I have it loaded, it's correct in the chart and excel, and I will test DDE when the market opens.

        Thanks for the heads up on the the plot scale and making the output text for the RSI. Is that what the +"" is after retVal_rsi in the return statement? I added a sub chart for RSI and it plots as it should.

        For reference, I included prior bar outputs for moving averages, and that is working in the code you sent also. Thanks - Carter

        Comment


        • #5
          Originally posted by ACM View Post
          Carter
          FWIW you do not need for the market to be open to test the DDE output as you can use Bar Replay
          Alex
          Alex, that's a great feature of bar replay to know about, thanks. I tested DDE with bar replay and everything is functional.
          Thanks again - Carter

          Comment


          • #6
            Glad it worked.

            Is that what the +"" is after retVal_rsi in the return statement?
            That is correct.
            Good to know ref: backtesting. I haven't used it.

            Wayne

            Comment


            • #7
              Originally posted by ACM View Post
              Carter
              FWIW you do not need for the market to be open to test the DDE output as you can use Bar Replay
              Alex
              Good to know. Thanks again.
              -Carter

              Comment

              Working...
              X