[TS] 피라미딩 코딩시 EntryPrice

by 정은희 posted Jan 28, 2019
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

TS에서  피라미딩을 두가지 방법으로 처리할수 있습니다
1. 하나의 챠트에 전략 여러개를  insert 하고  피라미딩 옵션을 주는 방법
2. 하나의 챠트에 하나의 전략안에 진입시그널을 여러개 넣고 피라미딩 옵션을 주는 방법

그런데 문제는 1번이든 2번이든 피라미딩으로 셋팅된 전략들이 Entriestoday, MarketPosition, EntryPrice 등을 공유합니다.
여러개의 진입시그널이 발생했더라도 EntryPrice 는 제일 처음 진입했던 값입니다.


아래는 2번의 방법으로 피라미딩 코딩시  각 시그널별로  entryprice 값을 배열에 셋팅하는 코딩입니다. 
(CurrentContracts 의 변화값과,  AvgEntryPrice 를 이용)

 

Arrays : EntryPrices[6](0);
        // pyramiding initialized
        if d>d[1] then begin
                EntryPrices[0] = 0;
                EntryPrices[1] = 0;
                EntryPrices[2] = 0;
                EntryPrices[3] = 0;
                EntryPrices[4] = 0;
                EntryPrices[5] = 0;
                EntryPrices[6] = 0;

                value30 = 0; // currentcontracts
                value31 = 0; // set #entry
                value32 = 0; // AvgEntryPrice        
        end;

        value30 = currentcontracts;
        value32 = AvgEntryPrice;

        // set entryprice
        if value30>value30[1] then begin
                EntryPrices[value31] = (value32*value30-value32[1]*value30[1])/(value30-value30[1]);
        end;
        


그런데, 한 봉에서 진입과 청산이 동시에 발생했을 경우, 매수와 매도 시그널이 함께 나올수 있는 전략들의 경우
entryprice 를 제대로 셋팅하지 못하는 문제가 있습니다.
피라미딩 코딩시 진입가를 제대로 셋팅할수 있는 방법이 있을까요?