Announcement

Collapse
No announcement yet.

Moving average of spreads on DDE excel

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

  • Moving average of spreads on DDE excel

    Dear Sir,

    I have been trying to get the simple moving average on the goog / aapl spread but the result is #NAME? on the excel.

    Can someone tell me the mistake in the following efs.

    var ddeSMA12 = null;
    var vMA = new MAStudy(12, 0, "Close", MAStudy.SIMPLE);

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

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

    var vSMA12 = vMA.getValue(MAStudy.MA);
    if (vSMA12 == null) return;

    ddeSMA12.set(vSMA12);

    return vSMA12;
    }

    In excel i am typeing =eSignal|efs!SMA12GOOG___AAPLD but the result is #NAME? .

    Do i have to write seperate EFS for the different spreads with different studies?

    Regards,
    Milind Vora

  • #2
    Re: Moving average of spreads on DDE excel

    Milind
    There are a couple of reasons why you are getting #NAME?
    The first one is due to an invalid use of the getSymbol() function. This function only returns the symbol being charted and does not accept any parameter so you would need to chart the GOOG / AAPL spread to retrieve its values and pass them to Excel
    In addition you are not replacing all the invalid characters in the string. In fact if you look at the output in the Formula Output Window you will see that the string is
    =eSignal|efs!SMA12GOOG__ AAPLD
    (notice the space after the two underscores) and not
    =eSignal|efs!SMA12GOOG___AAPLD
    To resolve you would need to replace the following line of code
    sName = sName.replace("/", "_") // replace STROK with underscore
    with
    sName = sName.replace("/ ", "_") // replace STROK with underscore
    and then use the following string for your DDE link
    =eSignal|efs!SMA12GOOG__AAPLD
    Alex


    Originally posted by kalpeshkrt2
    Dear Sir,

    I have been trying to get the simple moving average on the goog / aapl spread but the result is #NAME? on the excel.

    Can someone tell me the mistake in the following efs.

    var ddeSMA12 = null;
    var vMA = new MAStudy(12, 0, "Close", MAStudy.SIMPLE);

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

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

    var vSMA12 = vMA.getValue(MAStudy.MA);
    if (vSMA12 == null) return;

    ddeSMA12.set(vSMA12);

    return vSMA12;
    }

    In excel i am typeing =eSignal|efs!SMA12GOOG___AAPLD but the result is #NAME? .

    Do i have to write seperate EFS for the different spreads with different studies?

    Regards,
    Milind Vora

    Comment

    Working...
    X