+91-0000000000

}

Monday – Friday : 9:00 AM – 6:30 PM

Ehler Center of Gravity

The Ehler Center of Gravity in Amibroker calculates a center line based on price movements. Leveraging the Amibroker data feed, this indicator assists traders in determining potential turning points or trend reversals by analyzing price positioning around this center line.

/_SECTION_BEGIN("Ehlers Center of Gravity ");
//------------------------------------------------------------------------------

//
//  Ehlers Center of Gravity Oscillator is from Cybernetic Analysis for Stocks
//  and Futures. Wiley. 2004.
//
//  This indicator represents the center of gravity of prices over the window
//  of observation.
//
//------------------------------------------------------------------------------

SetBarsRequired(200, 0);

// Ehlers formulas
// from Ehlers, John F. Cybernetic Analysis for Stocks and Futures. Wiley. 2004. 
// Chapter 5, p. 47. Code on p. 49.

function CGOscillator(array, length)
// Figure 5.1 on p. 49.
{
  CGOValue = array;

  for(i = length; i < BarCount; i++)
  {
    num = 0;
    denom = 0;
    for(j = 0; j < length; j++)
    {
      num = num + (1 + j) * array[i - j];
      denom = denom + array[i - j];
    }
    if (denom != 0) CGOValue[i] = -num / denom + (length +1)/2;
  }
  return CGOValue;
}

med = (H + L) / 2;
Period = Param("Period", 10, 1, 250, 1);

Plot(CGOscillator(med, Period), "CG Oscillator", colorRed, styleLine);
Plot(Ref(CGOscillator(med, Period), -1), "Trigger", colorBlue, styleLine);
PlotGrid(.8);
PlotGrid(.5);
PlotGrid(.2);
_SECTION_END();

Open chat
1
Hi, how can I help you?