예스스탁
예스스탁 답변
2023-04-26 10:46:13
안녕하세요
예스스탁입니다.
올려주신 내용 별도로 오류는 없습니다.
아래와 같이 진입식 추가해서 적용해 보시기 바랍니다.
해당 내용으로 청산신호가 발생합니다.
input : SwingPeriod(2), AtrPeriod(10), ATrMult(3);
var : PH(0), PL(0), lastpp(0), center(0), alPHa(0), source(0), ATrV(0);
var : UpCh(0), DnCh(0), Trend(0), TuP(0), Tdown(0), TrailingSL(0);
# 스윙하이와 스윙로우를 이용하여 중심선 계산
PH = swingHigh(1,H,SwingPeriod,SwingPeriod,SwingPeriod*2+1);
PL = swingLow(1,L,SwingPeriod,SwingPeriod,SwingPeriod*2+1);
if PH <> -1 Then lastpp = PH;
if PL <> -1 Then lastpp = PL;
if PH <> -1 or PL <> -1 Then center = (center*2 + lastpp)/3;
# ATR계산(True Range를 RMA로 평균)
if CurrentBar > 0 Then {
alPHa = 1 / AtrPeriod ;
source = max(H - L, abs(H - C[1]), abs(L - C[1]));
ATrV = alPHa * source + (1 - alPHa) * ATrV[1];
}
# 상하단 채널과 추세에 따른 추세채널
UpCh = center - (ATrMult * ATrV);
DnCh = center + (ATrMult * ATrV);
Tup = IFf(C[1] > TUp[1],max(UpCh, TUp[1]),UpCh );
Tdown = IFf(C[1] < TDown[1],min(DnCh, TDown[1]),DnCh );
if C > TDown[1] Then Trend = 1;
if C < TuP[1] Then Trend = -1;
Trailingsl = IFf(Trend == 1, Tup, Tdown);
if crossup(ma(C,20),ma(c,60)) Then
Buy();
if CrossDown(ma(C,20),ma(c,60)) Then
Sell();
if MarketPosition == -1 and Trend == 1 and Trend[1] == -1 Then
ExitShort("sx");
if MarketPosition == 1 and Trend == -1 and Trend[1] == 1 Then
ExitLong("bx");
즐거운 하루되세요
> 마녀58 님이 쓴 글입니다.
> 제목 : 시스템 수식 문의 드립니다.
> https://blog.naver.com/chartist/222656653057
이 지표를 활용하여
"BuyStart"일때 매도청산
"SellStart"일때 매수청산
으로 활용하고 싶습니다.
이를 위해 기존시스템에
아래의 수식을 추가하였고
input : SwingPeriod(2), AtrPeriod(10), ATrMult(3);
var : PH(0), PL(0), lastpp(0), center(0), alPHa(0), source(0), ATrV(0);
var : UpCh(0), DnCh(0), Trend(0), TuP(0), Tdown(0), TrailingSL(0);
# 스윙하이와 스윙로우를 이용하여 중심선 계산
PH = swingHigh(1,H,SwingPeriod,SwingPeriod,SwingPeriod*2+1);
PL = swingLow(1,L,SwingPeriod,SwingPeriod,SwingPeriod*2+1);
if PH <> -1 Then lastpp = PH;
if PL <> -1 Then lastpp = PL;
if PH <> -1 or PL <> -1 Then center = (center*2 + lastpp)/3;
# ATR계산(True Range를 RMA로 평균)
if CurrentBar > 0 Then {
alPHa = 1 / AtrPeriod ;
source = max(H - L, abs(H - C[1]), abs(L - C[1]));
ATrV = alPHa * source + (1 - alPHa) * ATrV[1];
}
# 상하단 채널과 추세에 따른 추세채널
UpCh = center - (ATrMult * ATrV);
DnCh = center + (ATrMult * ATrV);
Tup = IFf(C[1] > TUp[1],max(UpCh, TUp[1]),UpCh );
Tdown = IFf(C[1] < TDown[1],min(DnCh, TDown[1]),DnCh );
if C > TDown[1] Then Trend = 1;
if C < TuP[1] Then Trend = -1;
Trailingsl = IFf(Trend == 1, Tup, Tdown);
매도청산식을 아래와 같이 작성하였으나 청산식이 작동하지 않았습니다.
if MarketPosition==-1 and Trend == 1 and Trend[1] == -1 Then
Exitshort("SX2",AtMarket);
이유와 해결법을 알고 싶습니다.
항상 감사드립니다.