Announcement

Collapse
No announcement yet.

Code simple simple........

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

  • Code simple simple........

    Code simple simple for understand the language of esignal :

    Example :
    I want to make one average of Close and one average of the average of close:

    Tradestation is:

    Var:sma1(0)sma2(0),mm3(0),s_sma(0),s_sma2(0),s_sma 3(0);

    sma1= average(Close,14);
    sma2= average(Close,20);

    s_sma = (sma1 + sma2); //add

    s_sma2 = average(s_sma,2); //average of add
    s_sma3 = average(s_sma2,2);
    // duble average(of average of add)

    plot(s_sma3);

    ___________________________

    In tradestation work perfectly but not in esignal :
    code esignal:

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("MA of PVI");
    setCursorLabelName("PVI",0);
    setCursorLabelName("MAofPVI",1);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.red, 1);
    }

    function main(Length,Lengthn){

    var sma1 = sma(14);
    var sma2 = sma(20);

    var s_sma = (sma1 + sma2);

    var s_sma2 = sma(2,s_sma);
    var s_sma3 = sma(2,s_sma2);

    return (s_sma3);

    }

    Error:
    Last edited by micman2; 07-09-2007, 05:48 AM.

  • #2
    Code simple simple........

    micman2
    The reason your script is not working is because in eSignal when you perform a math operation on a series (such as adding two series as you are doing with sma1+sma2) the result is a value and not a series which the sma() function instead requires.
    In order to do what you want you will need to first calculate the sum of sma1 and sma2 in a separate function (or efs) and then call that function (or efs) using either the efsInternal() or efsExternal() functions. This will create the series which you can then use as a source for the sma() function used to calculate s_sma2 and subsequently s_sma3
    For a more complete explanation and solution see this post in reply to a similar question. In that reply you will also find links to other examples on creating studies on studies using efs2 functions
    Alex


    Originally posted by micman2
    Code simple simple for understand the language of esignal :

    Example :
    I want to make one average of Close and one average of the average of close:

    Tradestation is:

    Var:sma1(0)sma2(0),mm3(0),s_sma(0),s_sma2(0),s_sma 3(0);

    sma1= average(Close,14);
    sma2= average(Close,20);

    s_sma = (sma1 + sma2); //add

    s_sma2 = average(s_sma,2); //average of add
    s_sma3 = average(s_sma2,2);
    // duble average(of average of add)

    plot(s_sma3);

    ___________________________

    In tradestation work perfectly but not in esignal :
    code esignal:

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("MA of PVI");
    setCursorLabelName("PVI",0);
    setCursorLabelName("MAofPVI",1);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.red, 1);
    }

    function main(Length,Lengthn){

    var sma1 = sma(14);
    var sma2 = sma(20);

    var s_sma = (sma1 + sma2);

    var s_sma2 = sma(2,s_sma);
    var s_sma3 = sma(2,s_sma2);

    return (s_sma3);

    }

    Error:

    Comment


    • #3
      micman2,

      The problem is that s_sma and s_sma2 are single values instead of a series.

      You can use the efsInternal function to convert them into a series.

      Steve

      Comment

      Working...
      X