Announcement

Collapse
No announcement yet.

Thrust Oscillator. I need help......

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

  • Thrust Oscillator. I need help......

    I got the code from Stock and Commodities Magazine and I need help getting it to work. Here is the code as they have it:

    }

    var EMA_1 = 0.0;

    function main(Length)
    {
    if(Length == null)
    Length = 22
    var K = 2 / (Length + 1);
    var TO = 0;
    var EMA = 0;
    if( getValue("close","$adv") * getValue("volume","$ADV") +
    getValue("close","$DECL") * getValue("volume","$DECL")!=0)
    TO = (getValue("close","$ADV") *
    getValue("volume","$ADV") - getValue("close","$DECL") *
    getValue("volume","DECL")) / (getValue("close","$ADV") *
    getValue("volume","$ADV") + getValue("close","DECL") *
    getValue("volume","$DECL"));
    EMA = K * TO +(1-K) * EMA_1;
    if (getBarState() ==BARSTATE_NEWBAR)
    EMA_1 = EMA;


    return new Array(TO,EMA);
    }

    I have no prgramming experience so I don't know where to start. If someone could get this thing to work that would be great. Many thanks in advance.

    Dave

  • #2
    That looks like it is misssing some data.

    An EFS will never start with just a } and there is no preMain(),
    so I suspect that is the end statement for a preMain() routine.

    Garth
    Garth

    Comment


    • #3
      This plots the oscillator part but the EMA still needs work.

      PHP Code:
      function preMain() {
          
      setCursorLabelName("TO"0);
          
      setCursorLabelName("EMA"1);
          
      setDefaultBarFgColor(Color.blue,0);
          
      setDefaultBarFgColor(Color.red,1);
      }

      var 
      EMA_1 0.0

      function 
      main(Length) {
          
          if(
      Length == nullLength 22
          
          
      var .5 * (Length 1);
          var 
      TO 0
          var 
      EMA 0
          
          var 
      advVol getValue("volume","$ADV");
          var 
      advClose getValue("close","$ADV");
          var 
      declVol getValue("volume","$DECL");
          var 
      declClose getValue("close","$DECL");
          
          var 
      numerator =   advClose advVol declClose declVol
          var 
      denominator advClose advVol declClose declVol
          if (
      denominator !=0TO numerator/denominator;
          
          
      EMA TO +(1-K) * EMA_1;
          
          if (
      getBarState() == BARSTATE_NEWBAREMA_1 EMA;
          
          return 
      TO;
          
          
      // return new Array(TO, EMA);

      Attached Files

      Comment


      • #4
        The completed formula can be found here
        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

        Working...
        X