Announcement

Collapse
No announcement yet.

Dinapoli's Detrended Oscillator

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

  • Dinapoli's Detrended Oscillator

    Hi, is there anyone that know how to add 2 moving average to this oscillator?
    I would to create 2 moving average, 1 fast and 1 slow, of this indicator, now I plot the code:


    function preMain()
    {
    setStudyTitle("DiNapoli Detrended Oscillator");
    setCursorLabelName("Detrend Osc",0);
    setDefaultBarFgColor(Color.red,0);
    addBand(0, PS_SOLID, 1, Color.black);
    }
    function main(nLength)
    {
    if (nLength == null)
    nLength = 50;

    var vPrice = getValue("Close",0,-nLength);
    if(vPrice == null)
    return;
    var Detrend = 0.0;
    var Sum = 0.0;
    var i = 0;

    //Average
    for (i = 0; i < nLength; i++)
    Sum += vPrice[i];
    Detrend = vPrice[0] - Sum / nLength;
    return Detrend;
    }

    thanks to everyone help me.

    P.S. Excuse me for my english...

  • #2
    ellerossi
    The easiest solution is to write another efs in which you will use the efsExternal() function to call your efs and create the series required by the moving average study.
    See this thread for an example used for a virtually identical request.
    The only difference would be that in your efsExternal() call you would need to add the nLength parameter required by the efs you are calling ie the DiNapoli Detrended Oscillator (see example below)
    Alex

    PHP Code:
    var myOsc efsExternal("path/name_of_file.efs"50);//50 is the length of the Oscillator
    //var myMA1 = see example indicated
    //var myMA2 = see example indicated 

    Comment


    • #3
      OK, thanks.
      Now I'll go to try. I'm a new Esignal's user and these are the first times that I try to code an indicator.
      If I have any problems I wirite again in this post.
      Thanks again

      Comment

      Working...
      X