Source for file ADX.php
Documentation is available at ADX.php
* Description: ADX Function
* @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
private $interpolate = true;
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
public function ADX($c= null) {
$this->HideSeries($this->iDMDown);
$tmpColor = new Color(255,0,0); // RED
$this->iDMDown->setColor($tmpColor);
$this->HideSeries($this->iDMUp);
$this->iDMUp->setColor(new Color(0,128,0)); // GREEN
/// Access characteristics of the DMDown line (a FastLineSeries).
/// DMDown is a sub-series (of type FastLine) of ADX function.
/// Access characteristics of the DMUp line (a FastLineSeries).
/// DMUp is a sub-series (of type FastLine) of ADX function.
/// The pen used to draw the upper ADX line.
/// Corresponds to DMUp.Pen property.
/// aDX.getUpLinePen().setColor(Color.Blue);
return $this->iDMUp->getLinePen();
/// The pen used to draw the lower ADX line.
/// Corresponds to DMDown.Pen property.
return $this->iDMDown->getLinePen();
return $value instanceof OHLC;
private function prepareSeries($series) {
$series->setChart($this->getSeries()->getChart());
$series->setCustomVertAxis($this->getSeries()->getCustomVertAxis());
$series->setVerticalAxis($this->getSeries()->getVerticalAxis());
$series->getXValues()->setDateTime($this->getSeries()->getXValues()->
/* TODO $series->addSeriesPaintListener( new SeriesPaintAdapter() {
public function seriesPainting($e) {
$this->ADX->this->getSeries()->doBeforeDrawChart();
public function seriesPainted($e) {
$this->ADX->this->getSeries()->doBeforeDrawChart();
private function calcADX($Index) {
abs($this->iDMUp->getYValues()->getValue($tmpIndex) -
$this->iDMDown->getYValues()->getValue($tmpIndex)) /
($this->iDMUp->getYValues()->getValue($tmpIndex) +
$this->iDMDown->getYValues()->getValue($tmpIndex)));
///Gets all points from Source series, performs a function operation and stores results in ParentSeries.
// base.AddPoints (source);
$s = $source->offsetget(0);
if ($s->getCount() > 0) {
$this->prepareSeries($this->iDMUp);
$this->prepareSeries($this->iDMDown);
if ($s->getCount() >= (2 * $this->getPeriod())) {
$this->Closes = $s->getCloseValues();
$this->Highs = $s->getHighValues();
$this->Lows = $s->getLowValues();
$tmpTR[] = $s->getCount();
$tmpDMUp[] = $s->getCount();
$tmpDMDown[] = $s->getCount();
for ( $t = 1; $t < $s->getCount(); ++ $t) {
$tmpClose = $this->Closes->getValue($t - 1);
$tmpTR[$t] = $this->Highs->getValue($t) - $this->Lows->getValue($t);
$tmpTR[$t] = max($tmpTR[$t],
abs($this->Highs->getValue($t) - $tmpClose));
$tmpTR[$t] = max($tmpTR[$t],
abs($this->Lows->getValue($t) - $tmpClose));
if (($this->Highs->getValue($t) - $this->Highs->getValue($t - 1)) >
($this->Lows->getValue($t - 1) - $this->Lows->getValue($t))) {
$this->Highs->getValue($t) -
$this->Highs->getValue($t - 1));
if (($this->Lows->value[$t - 1] - $this->Lows->value[$t]) >
($this->Highs->value[$t] - $this->Highs->value[$t - 1])) {
$this->Lows->getValue($t - 1) -
$this->Lows->getValue($t));
for ( $t = $tmp; $t < $s->getCount(); ++ $t) {
$tmpTR2 = $tmpTR2 + $tmpTR[$tt];
$tmpUp2 = $tmpUp2 + $tmpDMUp[$tt];
$tmpDown2 = $tmpDown2 + $tmpDMDown[$tt];
$tmpTR2 = $tmpTR2 - ($tmpTR2 / $this->getPeriod()) +
$tmpUp2 = $tmpUp2 - ($tmpUp2 / $this->getPeriod()) +
$tmpDown2 = $tmpDown2 - ($tmpDown2 / $this->getPeriod()) +
$tmpX = $s->getXValues()->getValue($t);
$this->iDMUp->add($tmpX, 100 * ($tmpUp2 / $tmpTR2));
$this->iDMDown->add($tmpX, 100 * ($tmpDown2 / $tmpTR2));
for ( $t = $tmp; $t < $s->getCount(); ++ $t) {
$tmpADX = $tmpADX + $this->calcADX($tt);
$tmpADX = $tmpADX / ($this->getPeriod() - 1);
$tmpADX = (($tmpADX * ($this->getPeriod() - 1)) +
$this->getSeries()->add($s->getXValues()->getValue($t),
private function HideSeries($ASeries) {
$ASeries->setShowInLegend(false);
$ASeries->InternalUse = true;
protected function dispose($disposing) {
$this->iDMDown->dispose();
|