Source for file OHLC.php
Documentation is available at OHLC.php
* Description: OHLC is an base Series class that maintains lists for Open,
* Close, High and Low values
* @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
* @link http://www.steema.com
function __get( $property ) {
$method = "get{$property}";
function __set ( $property,$value ) {
$method = "set{$property}";
return $this->$method($value);
public function OHLC($c= null) {
$this->getXValues()->setName("ValuesDate"); // TODO $this->Language->getString("ValuesDate");
$this->getYValues()->setName("ValuesClose"); // TODO $this->Language->getString("ValuesClose");
$this->vHighValues = new ValueList($this, "ValuesHigh"); // TODO $this->Language->getString("ValuesHigh"));
$this->vLowValues = new ValueList($this, "ValuesLow"); // TODO $this->Language->getString("ValuesLow"));
$this->vOpenValues = new ValueList($this, "ValuesOpen"); //$this->Language->getString("ValuesOpen"));
* All the Stock market Date values.
* You can access Date values in the same way you can access X or Y values.
* Sets all Stock market Date values.
* You can access Date values in the same way you can access X or Y values.
* @param ValueList $value
* All the Stock market Close values.
* You can access Close values in the same way you can access X or Y values.
* Sets all Stock market Close values.
* You can access Close values in the same way you can access X or Y values.
* @param ValueList $value
* All the Stock market Open values.
* You can access Open values in the same way you can access X or Y values.
* Sets all Stock market Open values.
* You can access Open values in the same way you can access X or Y values.
* @param ValueList $value
* All the Stock market High values.
* You can access High values in the same way you can access X or Y values.
* Sets all Stock market High values.<br>
* You can access High values in the same way you can access X or Y values.
* All the Stock market Low values.<br>
* You can access High values in the same way you can access X or Y values.
* Sets all Stock market Low values.<br>
* You can access High values in the same way you can access X or Y values.
* Adds new point with specified integer index and double open, high,
* @return int index of added point
/* TODO remove public function add($index, $open, $high, $low,$close) {
return $this->add($tmp, $open, $high, $low, $close);
* Adds new point with specified double index and double open, high, low
* @return int index of added point
public function addCandle($index, $open, $high, $low, $close,$text= "") {
return $this->addXY($index, $close);
return $this->addXYText($index, $close,$text);
* Adds new point with specified double open, high, low and close.
* @return int index of added point
/* TODO public function add($open, $high, $low, $close) {
return $this->add($this->getCount(), $open, $high, $low, $close);
* Adds new point with specified DateTime x and double open, high, low
* @return int index of added point
public function addCandleDate($aDate, $open, $high, $low, $close) {
return $this->add($aDate->toDouble(), $open, $high, $low, $close);
* Adds the DataView to the OHLC series.
* Validates Series datasource.
* @param value ISeries the series to validate.
* @return boolean true if value can be a Series data source.
return $value instanceof OHLC;
* The Maximum Value of the Series Y Values List.
* The Minimum Value of the Series Y Values List.<br>
* As some Series have more than one Y Values List, this Minimum Value is
* the "Minimum of Minimums" of all Series Y Values lists.
$aOpen = $r->MinY + MathUtils::round($r->DifY * $r->Random()); // open price
for ( $t = 1; $t <= $numValues; $t++ ) {
// Generate random figures
$ohlc = $this->getRandomOHLC($r, $aOpen, $r->DifY);
// Call the standard add method
$this->addCandle($r->tmpX, $aOpen, $ohlc->aHigh, $ohlc->aLow, $ohlc->aClose);
$r->tmpX += $r->StepX; // <-- X value
// Tomorrow, the market will open at today's close plus/minus something
$aOpen = $ohlc->aClose + (10 * $r->Random()) - 5;
* @return SeriesOHLCPoint
return new SeriesOHLCPoint($this, $index);
private function getRandomOHLC($rr, $aOpen,$yRange) {
$r->aClose = $aOpen + MathUtils::round($yRange / 25.0) * $rr->Random() -
($this->yRange / 50.0); /* close price->->-> */
/* and imagine the high and low session price */
if ($r->aClose > $aOpen) {
$r->aHigh = $r->aClose + $tmpFixed + $tmpY * $rr->Random();
$r->aLow = $aOpen - $tmpFixed - $tmpY * $rr->Random();
$r->aHigh = $aOpen + $tmpFixed + $tmpY * $rr->Random();
$r->aLow = $r->aClose - $tmpFixed - $tmpY * $rr->Random();
|