라이브러리

[PHP] trader_adxr - 평균 방향성 이동 지수 등급




ADX (Average Directional Index)와 ADXR (Average Directional Index Rate)

ADX (Average Directional Index)는 기술적 분석에서 사용되는 지표로, 가격의 변동을 분석하여 시장의 추세를 파악하는 데 사용됩니다. ADXR (Average Directional Index Rate)는 ADX와 유사한 지표로, 가격의 변동을 분석하여 시장의 추세를 파악하는 데 사용됩니다.

Trader_ADXR 클래스

PHP에서 Trader_ADXR 클래스를 생성하여 ADXR 지표를 계산하는 방법을 설명하겠습니다.

#hostingforum.kr
php

class Trader_ADXR {

    private $high;

    private $low;

    private $close;

    private $adx;

    private $adxr;



    public function __construct($high, $low, $close) {

        $this->high = $high;

        $this->low = $low;

        $this->close = $close;

    }



    public function calculate_adx() {

        $up = array();

        $down = array();

        for ($i = 0; $i < count($this->high); $i++) {

            $up[$i] = max(0, $this->high[$i] - $this->high[$i - 1]);

            $down[$i] = max(0, $this->high[$i - 1] - $this->high[$i]);

        }



        $up_sum = array_sum($up);

        $down_sum = array_sum($down);



        $adx = 0;

        for ($i = 1; $i < count($up); $i++) {

            $adx = 14 * ($up_sum[$i] - $down_sum[$i]) / ($up_sum[$i] + $down_sum[$i]) + (1 - 0.066) * $adx;

        }



        $this->adx = $adx;

    }



    public function calculate_adxr() {

        $up = array();

        $down = array();

        for ($i = 0; $i < count($this->high); $i++) {

            $up[$i] = max(0, $this->high[$i] - $this->high[$i - 1]);

            $down[$i] = max(0, $this->high[$i - 1] - $this->high[$i]);

        }



        $up_sum = array_sum($up);

        $down_sum = array_sum($down);



        $adxr = 0;

        for ($i = 1; $i < count($up); $i++) {

            $adxr = 14 * ($up_sum[$i] - $down_sum[$i]) / ($up_sum[$i] + $down_sum[$i]) + (1 - 0.066) * $adxr;

        }



        $this->adxr = $adxr;

    }



    public function get_adx() {

        return $this->adx;

    }



    public function get_adxr() {

        return $this->adxr;

    }

}



예제

#hostingforum.kr
php

$high = array(10, 12, 15, 18, 20, 22, 25, 28, 30, 32, 35, 38, 40, 42, 45, 48, 50, 52, 55, 58, 60, 62, 65, 68, 70, 72, 75, 78, 80, 82, 85, 88, 90, 92, 95, 98, 100);

$low = array(5, 7, 10, 12, 15, 18, 20, 22, 25, 28, 30, 32, 35, 38, 40, 42, 45, 48, 50, 52, 55, 58, 60, 62, 65, 68, 70, 72, 75, 78, 80, 82, 85, 88, 90, 92, 95, 98, 100);

$close = array(8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84);



$adxr = new Trader_ADXR($high, $low, $close);

$adxr->calculate_adx();

$adxr->calculate_adxr();



echo "ADX: " . $adxr->get_adx() . "
";

echo "ADXR: " . $adxr->get_adxr() . "
";



이 예제에서는 Trader_ADXR 클래스를 사용하여 ADXR 지표를 계산하고, ADX와 ADXR의 값을 출력합니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 8,985건 / 80 페이지

검색

게시물 검색