Announcement

Collapse
No announcement yet.

EFS code

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

  • EFS code

    hello

    i have Metastock Formula and will import in eSignal EFS Code

    can help me please

    ENTER LONG IF

    -------------------------------------------------------
    EL:=H>Ref(HHV(H,20),-1);
    CL:=L<Ref(LLV(L,10),-1);
    ES:=L<Ref(LLV(L,20),-1);
    CS:=H>Ref(HHV(H,10),-1);

    State:=If(***(1)=1,0,If(EL,1,If(ES,-1,If((CL AND PREV=1) OR (CS AND PREV=-1),0,PREV))));

    State=1 AND Ref(State,-1)<1
    --------------------------------------------------------


    Thanks
    MfG

  • #2
    Here is the beginning..

    The issues I had with trying to help you is the following...

    *** - unknown to me
    Prev = unknown variable/condition
    State = calculation of unknown variables.

    Basically, I have created the "beginning" of your code with "user inputs" and a "High/Low lookback" function.

    You should start with what I am providing and try to accomplish the rest. If you can detail what the rest of the code is doing, then I will try to assist you.

    Brad
    Attached Files
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      hello
      thanks for you help

      The Trading-System Name = Turtle Breakout 1

      --------------------------------------------------------------------------------
      You are using the PREV variable in a location within a custom indicator that will cause the calculation to be very slow. You should normally try to avoid using the PREV variable as a DATA ARRAY when there is also a PERIODS specified (e.g., mov(prev, 20, s), hhv(prev, 30), etc.). Although use of the PREV function in this way is allowable, it will take a long time to calculate, particularly if a lot of data is loaded in the chart.

      The PREV constant allows you to create self-referencing formulas. A self referencing formula is one that is able to reference the "previous" period's value of itself.
      For example, the following is an example of a self referencing formula:
      ((H+L+C)/3) + PREV
      This simple formula divides the high, low, and closing prices by 3 and then adds this value to yesterday's value of the ((H+L+C)/3).
      The calculation of the popular indicator On Balance Volume illustrates the use of the PREV function.

      (if(c>ref(c,-1),1,-1)*volume)+PREV
      Although On Balance Volume can be calculated without the use of the PREV function, an exponential moving average cannot (other than using the mov() function). The following formula shows how a 18% exponential moving average (approximately 10-periods) is calculated using the PREV function.
      (close*0.18)+(PREV*0.82)
      -----------------------------------------------------------------------------------



      -----------------------------------------------------------------------------------
      SYNTAX ***( DATA ARRAY )

      FUNCTION Calculates a cumulative sum of the DATA ARRAY from the first period in the chart.

      EXAMPLE The formula "***( 1 )" calculates an indicator that rises one point for each day since the beginning of the chart; the formula "***( C )" calculates the cumulative total of all closing prices from the beginning of the chart
      -----------------------------------------------------------------------------------


      -----------------------------------------------------------------------------------
      State is variable is only 1 or -1
      ----------------------------------------------------------------------------------



      here is the complett Code for Trading System (Turtle Breakout 1)

      ENTER LONG
      --------------------------------------------------------------------------------
      EL:=H>Ref(HHV(H,20),-1);
      CL:=L<Ref(LLV(L,10),-1);
      ES:=L<Ref(LLV(L,20),-1);
      CS:=H>Ref(HHV(H,10),-1);

      State:=If(***(1)=1,0,If(EL,1,If(ES,-1,If((CL AND PREV=1) OR (CS AND PREV=-1),0,PREV))));

      State=1 AND Ref(State,-1)<1
      ----------------------------------------------------------------------------------



      ENTER SHORT
      ---------------------------------------------------------------------------------
      EL:=H>Ref(HHV(H,20),-1);
      CL:=L<Ref(LLV(L,10),-1);
      ES:=L<Ref(LLV(L,20),-1);
      CS:=H>Ref(HHV(H,10),-1);

      State:=If(***(1)=1,0,If(EL,1,If(ES,-1,If((CL AND PREV=1) OR (CS AND PREV=-1),0,PREV))));

      State=-1 AND Ref(State,-1)>-1
      ----------------------------------------------------------------------------------



      EXIT LONG
      ----------------------------------------------------------------------------------
      EL:=H>Ref(HHV(H,20),-1);
      CL:=L<Ref(LLV(L,10),-1);
      ES:=L<Ref(LLV(L,20),-1);
      CS:=H>Ref(HHV(H,10),-1);

      State:=If(***(1)=1,0,If(EL,1,If(ES,-1,If((CL AND PREV=1) OR (CS AND PREV=-1),0,PREV))));

      State=0 AND Ref(State,-1)=1
      ----------------------------------------------------------------------------------



      EXIT SHORT
      ----------------------------------------------------------------------------------
      EL:=H>Ref(HHV(H,20),-1);
      CL:=L<Ref(LLV(L,10),-1);
      ES:=L<Ref(LLV(L,20),-1);
      CS:=H>Ref(HHV(H,10),-1);

      State:=If(***(1)=1,0,If(EL,1,If(ES,-1,If((CL AND PREV=1) OR (CS AND PREV=-1),0,PREV))));

      State=0 AND Ref(State,-1)=-1
      -----------------------------------------------------------------------------------


      SYSTEM FINISH


      result

      if

      State = 1 or -1
      EL = 1 or -1
      CL = 1 or -1
      ES = 1 or -1
      CS = 1 or -1


      THANKS
      Mfg

      Comment


      • #4
        A little more help...

        Let's concentrate on these statements, then I will have something that will work for you..

        first...

        State:=If(***(1)=1,0,If(EL,1,If(ES,-1,If((CL AND PREV=1) OR (CS AND PREV=-1),0,PREV))));

        I understand the If,Then,Else routines here and the fact that this is a nested if statement, but if I break it down.. I end up with this...

        If(***(1)=1) then State =0
        If(EL=true) then State =1
        If(ES=true) then State =-1
        If((CL AND PREV=1) OR (CS AND PREV=-1)) then State = 0
        Otherwise State = PREV

        The question I have is as follows..

        If ***(1) = 1 and we return ZERO, then ***(1) will always = 1 - so the code will never do anything. The rest of this statement is pretty clear.

        Second...

        State=1 AND Ref(State,-1)<1

        What is this (an if statement or a statement setting variable conditions)?? It kind of hangs out there and does not really tell me if this is a statement to do anything or not.

        If these conditions are TRUE, then what?? What is it supposed to do??

        Thanks for your help.

        Brad
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          hello

          the formula for BUY, SELL, EXIT is only

          EL:=H>Ref(HHV(H,20),-1); // if EL = true then BUY
          CL:=L<Ref(LLV(L,10),-1); // if CL = true then EXIT BUY
          ES:=L<Ref(LLV(L,20),-1); // if ES = true then SELL
          CS:=H>Ref(HHV(H,10),-1); // if CS = true then EXIT SELL

          the rest Code is sorting for Signal

          also


          if Buy Signal then ingnore EL Variable pend comming differently SIGNAL


          Sorry my English is not good comming from Germany

          Comment


          • #6
            Thanks.. Here you go...

            Finger,

            Thanks for the help in understanding this MS formula.

            Here you go..

            This code should be doing exactly what you want.
            Including...

            Graphics (showing BUY and SELL signals and EXITS)
            Back-testing capabilities
            User-Inputs to change the values (10,20).

            If you have any other questions, please let me know.

            Brad
            Attached Files
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment

            Working...
            X