본문 바로가기
트레이딩

Trailing Stop 관련 변수 정의. 수도코드.

by i.got.it 2017. 6. 3.

 

 

 

 

매수진입인 경우.

 

 

Definitions & Relations.

 

PriceDiff ProfitMaxHold

- PriceDiff ProfitMaxHold = Price Item - Price Entry(Buy)

 

Price ProfitMaxHold

- 아이템 가격이 진입가격 이상인 경우 정의.

- Price ProfitMaxHold = Price Entry(Buy).  + PriceDiff ProfitMaxHold

 

Price Exit

- 청산 기준 가격. 아이템 가격이 Price Exit 이하인 경우 청산 주문 시행.

- Price Exit = Price ProfitMaxHold – PriceDiff_Exit.

 

PriceDiff_Exit

아이템가격이 Price ProfitMaxHold 이하 어느정도일 때 청산주문 시행할지 기준범위. 매매대상 종목의 가격변화 특성 고려하여 설정되어야 함.

 

 


 

매도진입인 경우.

 

 

 

Definitions & Relations.

 

PriceDiff ProfitMaxHold

- PriceDiff ProfitMaxHold = Price Entry(Sell) - Price Item.

 

Price ProfitMaxHold

- 아이템 가격이 진입가격 이하인 경우 정의.

- Price ProfitMaxHold = Price Entry(Sell) - PriceDiff ProfitMaxHold.

 

Price Exit

- 청산 기준 가격. 아이템 가격이 Price Exit 이상인 경우 청산 주문 시행.

- Price Exit = Price ProfitMaxHold + PriceDiff_Exit.

 

PriceDiff_Exit

아이템 가격이 Price ProfitMaxHold 이상 어느정도에서 청산주문 시행할지 기준범위. 매매대상 종목의 가격변화 특성 고려하여 설정되어야 함.

 


 

 

수도코드.

 

코드요점

:

매번의 가격변동시점마다 최종

Price Exit

값 갱신해야하며

,

이를 위하여 아래와 같은 과정 거친다

.

 


매수진입인 경우,


PriceDiff Profit = Price Item – Price Entry(Buy);


If (PriceDiff Profit > 0 ) {


If (PriceDiff Profit  > PriceDiff ProfitMaxHold) { //
이전 값보다 더 크다면.


PriceDiff ProfitMaxHold = PriceDiff Profit; //
신규 고가로 갱신.


Price ProfitMaxHold = PriceDiff ProfitMaxHold + Price Entry(Buy); //
신규고가 갱신.


Price Exit = Price ProfitMaxHold – PriceDiff Exit; // PriceDiff Exit 만큼 더 낮은 가격으로 설정.


}


}


 


매도진입인 경우,


PriceDiff Profit = Price Entry(Sell) - Price Item;


If (PriceDiff Profit > 0 ) {


If (PriceDiff Profit  > PriceDiff ProfitMaxHold) { //
이전 값보다 더 크다면.


PriceDiff ProfitMaxHold = PriceDiff Profit; //
신규 고가로 갱신.


Price ProfitMaxHold = Price Entry(Buy) - PriceDiff ProfitMaxHold; //
신규저가격 갱신.


Price Exit = Price ProfitMaxHold + PriceDiff Exit; // PriceDiff Exit만큼 더 높은가격으로 갱신.


}


}

 

 

 

 

 

///1314.

 

댓글



 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5