라이브러리

[PHP] trader_cdlladderbottom - 사다리 바닥




트레이딩 전략: 트레이더 CDL Ladder Bottom

트레이딩 전략은 투자자들이 시장의 움직임을 예측하고 투자 결정을 내릴 때 사용하는 전략입니다. CDL Ladder Bottom은 한 가지 유형의 기술적 분석 전략입니다.

CDL Ladder Bottom이란?

CDL Ladder Bottom은 한 번에 여러 개의 저점을 형성하고, 그 사이에 상승하는 가격 움직임을 나타내는 전략입니다. 이 전략은 가격이 이전 저점보다 더 낮은 가격에 새로운 저점을 형성할 때 발생합니다.

PHP에서 CDL Ladder Bottom 구현하기

PHP에서 CDL Ladder Bottom 전략을 구현하는 방법은 다음과 같습니다.

#hostingforum.kr
php

class CDLLadderBottom {

    private $data; // 데이터 배열

    private $low; // 저점 배열

    private $high; // 고점 배열

    private $ladderBottom; // 라더 밑 전략 결과



    public function __construct($data) {

        $this->data = $data;

        $this->low = array();

        $this->high = array();

        $this->ladderBottom = array();

    }



    public function calculate() {

        // 데이터를 처리하여 저점과 고점을 찾습니다.

        foreach ($this->data as $i => $value) {

            if ($i > 0 && $value['low'] < $this->data[$i-1]['low']) {

                $this->low[] = $value['low'];

            }

            if ($i > 0 && $value['high'] > $this->data[$i-1]['high']) {

                $this->high[] = $value['high'];

            }

        }



        // 라더 밑 전략을 적용합니다.

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

            if ($i > 0 && $this->low[$i] < $this->low[$i-1]) {

                $this->ladderBottom[] = array(

                    'low' => $this->low[$i],

                    'high' => $this->high[$i],

                    'index' => $i

                );

            }

        }

    }



    public function getLadderBottom() {

        return $this->ladderBottom;

    }

}



// 예제 데이터

$data = array(

    array('date' => '2022-01-01', 'low' => 100, 'high' => 120),

    array('date' => '2022-01-02', 'low' => 90, 'high' => 110),

    array('date' => '2022-01-03', 'low' => 80, 'high' => 100),

    array('date' => '2022-01-04', 'low' => 70, 'high' => 90),

    array('date' => '2022-01-05', 'low' => 60, 'high' => 80),

    array('date' => '2022-01-06', 'low' => 50, 'high' => 70),

    array('date' => '2022-01-07', 'low' => 40, 'high' => 60),

    array('date' => '2022-01-08', 'low' => 30, 'high' => 50),

    array('date' => '2022-01-09', 'low' => 20, 'high' => 40),

    array('date' => '2022-01-10', 'low' => 10, 'high' => 30)

);



// CDL Ladder Bottom 전략을 적용합니다.

$cdl = new CDLLadderBottom($data);

$cdl->calculate();



// 결과를 출력합니다.

print_r($cdl->getLadderBottom());



이 예제에서는 CDL Ladder Bottom 전략을 적용하여 데이터에서 라더 밑을 찾습니다. 결과는 다음과 같습니다.

#hostingforum.kr
php

Array

(

    [0] => Array

        (

            [low] => 70

            [high] => 90

            [index] => 3

        )



    [1] => Array

        (

            [low] => 50

            [high] => 70

            [index] => 5

        )



    [2] => Array

        (

            [low] => 30

            [high] => 50

            [index] => 7

        )



    [3] => Array

        (

            [low] => 10

            [high] => 30

            [index] => 9

        )



)



이 결과는 CDL Ladder Bottom 전략이 데이터에서 라더 밑을 찾은 결과입니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

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

검색

게시물 검색