커뮤니티
예스랭귀지 Q&A
답변완료
[공지] 예스랭귀지 AI 어시스턴트, '예스나 AI' 출시 및 무료 체험 안내
안녕하세요, 예스스탁 입니다.복잡한 수식 공부 없이 여러분의 아이디어를 말하면 시스템 트레이딩 언어 예스랭귀지로 작성해주는 서비스예스나 AI(YesNa AI)가 출시되었습니다.지금 예스나 AI를 직접 경험해 보실 수 있도록 20크레딧(질문권 20회)를 무료로 증정해 드리고 있습니다.바로 여러분의 아이디어를 코드로 변환해보세요.--------------------------------------------------🚀 YesNa AI 핵심 기능- 지표식/전략식/종목검색식 생성: 자연어로 요청하면 예스랭귀지 문법에 맞는 코드를 작성합니다.- 종목검색식 변환 지원: K증권의 종목 검색식을 예스랭귀지로 변환 지원합니다.- 컴파일 검증: 작성된 코드가 실행 가능한지 컴파일러를 통해 문법 검증을 거쳐 결과물을 제공합니다.상세한 서비스 개요 및 활용 방법은 [서비스 소개 페이지]에서 확인하실 수 있습니다.▶ 서비스 소개 페이지: 바로가기서비스 사용 유의사항 및 결제 환불정책은 [이용약관]을 참고 부탁드립니다.▶ 서비스 이용약관: 바로가기💬 이용 문의사용 중 문의사항은 [프로그램 사용법 Q&A] 게시판에서 [예스나 AI] 카테고리를 설정 후 문의해 주시면 상세히 안내해 드리겠습니다.--------------------------------------------------앞으로도 AI를 활용한 다양한 트레이딩 기능들을 지속적으로 선보일 예정입니다.많은 관심과 기대 부탁드립니다.
2026-02-27
6525
글번호 230811
답변완료
문의드립니다
이동평균 5, 20 골든크로스 매수신호
매수신호 봉의 저가이하에서 매수
진입가격에 +0.3%이상 수익중이고 이동평균 5, 20 데드크로스 매도
부탁드립니다
2015-10-30
190
글번호 91901
답변완료
로직 추가 문의
답변 감사합니다.
아래 글에서 한가지만 추가 문의합니다.
아래 2)번 답변, 십자봉미포함 로직에서
십자봉이 2번째 뜨는 경우는 제외하고, 첫번째 뜨는 경우엔
매매신호 나오게 가능합니까?
예로, 빨간봉이 2개 연속 나오는데,
1) 첫째봉 빨간봉(십자봉 아님), 두번째봉 빨간봉(십자봉) => 신호없음.
2) 첫재봉 십자봉, 둘째봉 십자봉 아닌 경우 => 신호나옴.
이렇게 2)경우만 매수신호 나오게 하는 경우입니다.
--------------------------------------------------------------------
안녕하세요
예스스탁입니다.
1.
input : N(2);
if dayindex+1 >= N then{
if countif(C>O or (C == O and c >= C[1]),N) == N Then
buy();
if countif(C<O or (C == O and c < C[1]),N) == N Then
sell();
}
2.
input : N(2);
if dayindex+1 >= N then{
if countif(C>O,N) == N Then
buy();
if countif(C<O,N) == N Then
sell();
}
즐거운 하루되세요
> 초록이 님이 쓴 글입니다.
> 제목 : 로직 재문의
> 아래글에 대한 2가지 재문의입니다.
1) 아래 로직을 적용해보니, 첫봉에서 매매신호가 뜨는 경우가
발생합니다.
예로, 전일 마지막봉이 빨간봉이고, 당일 첫봉이 빨간봉이면
빨간봉이 2개 연속뜬것으로 인식해 매수신호가 나옵니다.
전일봉은 무시하고, 당일 첫봉부터만 적용되도록 가능합니까?
2)아래 로직에서 십자봉을 제외한 로직은 어떻게 됩니까?
===========================================================
예스스탁입니다.
if countif(C>O or (C == O and c >= C[1]),2) == 2 Then
buy();
if countif(C<O or (C == O and c < C[1]),2) == 2 Then
sell();
즐거운 하루되세요
> 초록이 님이 쓴 글입니다.
> 연결선물지수 3분봉을 하고 잇읍니다.
봉 색깔이 2개 연속 빨간봉이면 매수, 2개연속 파란봉이면 매도
이렇게 하고 싶읍니다.
해당봉 종가가 직전봉 종가 대비 상승 또는 하락 여부는 따지지
않고, 오로지 봉 색깔만을 변수로 하고자 합니다.
(십자봉도 포함시키되, 십자봉 역시 봉 색깔만을 고려합니다).
매수,매도 포지션 모두 로직 부탁합니다.
2015-11-02
198
글번호 91900
답변완료
문의드립니다.
안녕하세요
1. 해외선물 주봉 차트에서 이번달 최고 거래량이 발생한 주봉의 고저와 저번달 최고 거래량이 발생한 주봉의 고저를 분봉에 나타나게 하는 지표식
2. 해외선물 일봉 차트에서 이번주 최고 거래량이 발생한 일봉의 고저와 저번주 최고 거래량이 발생한 일봉의 고저를 분봉에 나타나게 하는 지표식을 부탁드립니다.
감사합니다.
2015-10-30
197
글번호 91899
답변완료
부탁 드립니다.
항상 도움 주셔서 깊이 감사 드립니다.
질문1)YT변환 부탁 드립니다
sum(if(C>C(1),C-min(C(1),L),0))+sum(if(C<C(1),C-max(C(1),H),0))
질문2) 다음을 상승시 체결음과 하락시 체결음으로 구분할수 있는지요?
PlaySound( "C:₩eFriend Global YesTraderefriendglobalyestrader₩data₩Sound₩alert.wav");
질문3)
하루전의 08:00 에서
금일 07:00 까지
대륙별 거래시간 표시 부탁 드립니다.
-당일용-> 당일것만 표시
-전일용-> 전일의 아시아,유럽,미국장 표시
질문4)
그림과 같이 표시 부탁 드립니다.
가급적 TL선의 중간 또는 우측에 부탁 드립니다.
미리 감사 드립니다.
input : 아시아시작(081000),아시아종료(152000);
input : 유럽시작(153000),유럽종료(213000);
input : 미국시작(214000),미국종료(065000);
var : D1(0),T1(0),H1(0),L1(0),Tcond1(false);
var : D2(0),T2(0),H2(0),L2(0),Tcond2(false);
var : D3(0),T3(0),H3(0),L3(0),Tcond3(false);
var : TL11(0),TL12(0),TL13(0),TL14(0);
var : TL21(0),TL22(0),TL23(0),TL24(0);
var : TL31(0),TL32(0),TL33(0),TL34(0);
if stime == 아시아시작 or (stime > 아시아시작 and stime[1] < 아시아시작) Then{
D1 = sdate;
T1 = stime;
H1 = H;
L1 = L;
Tcond1 = true;
}
if Tcond1 == true Then{
if H > H1 Then
H1 = H;
if L < L1 Then
L1 = L;
TL_Delete(TL11);
TL_Delete(TL12);
TL_Delete(TL13);
TL_Delete(TL14);
TL11 = TL_New(D1,T1,H1,Sdate,stime,H1);
TL12 = TL_New(D1,T1,L1,Sdate,stime,L1);
TL13 = TL_New(D1,T1,H1,D1,T1,L1);
TL14 = TL_New(sdate,stime,H1,sdate,stime,L1);
TL_SetColor(TL11,RED);
TL_SetColor(TL12,RED);
TL_SetColor(TL13,RED);
TL_SetColor(TL14,RED);
}
if time == 아시아종료 or (time > 아시아종료 and time[1] < 아시아종료) Then
Tcond1 = false;
if stime == 유럽시작 or (stime > 유럽시작 and stime[1] < 유럽시작) Then{
D2 = sdate;
T2 = stime;
H2 = H;
L2 = L;
Tcond2 = true;
}
if Tcond2 == true Then{
if H > H2 Then
H2 = H;
if L < L2 Then
L2 = L;
TL_Delete(TL21);
TL_Delete(TL22);
TL_Delete(TL23);
TL_Delete(TL24);
TL21 = TL_New(D2,T2,H2,Sdate,stime,H2);
TL22 = TL_New(D2,T2,L2,Sdate,stime,L2);
TL23 = TL_New(D2,T2,H2,D2,T2,L2);
TL24 = TL_New(sdate,stime,H2,sdate,stime,L2);
TL_SetColor(TL21,YELLOW);
TL_SetColor(TL22,YELLOW);
TL_SetColor(TL23,YELLOW);
TL_SetColor(TL24,YELLOW);
}
if time == 유럽종료 or (time > 유럽종료 and time[1] < 유럽종료) Then
Tcond2 = false;
if stime == 미국시작 or (stime > 미국시작 and stime[1] < 미국시작) Then{
D3 = sdate;
T3 = stime;
H3 = H;
L3 = L;
Tcond3 = true;
}
if Tcond3 == true Then{
if H > H3 Then
H3 = H;
if L < L3 Then
L3 = L;
TL_Delete(TL31);
TL_Delete(TL32);
TL_Delete(TL33);
TL_Delete(TL34);
TL31 = TL_New(D3,T3,H3,Sdate,stime,H3);
TL32 = TL_New(D3,T3,L3,Sdate,stime,L3);
TL33 = TL_New(D3,T3,H3,D3,T3,L3);
TL34 = TL_New(sdate,stime,H3,sdate,stime,L3);
TL_SetColor(TL31,BLUE);
TL_SetColor(TL32,BLUE);
TL_SetColor(TL33,BLUE);
TL_SetColor(TL34,BLUE);
}
if time == 미국종료 or (time > 미국종료 and time[1] < 미국종료) Then
Tcond3 = false;
2015-11-02
281
글번호 91898
답변완료
지표부탁드립니다
지표식을 부탁드립니다
1 특정주가 기준 퍼센트 채널
특정주가(250)(변수처리가능) 을 기준으로 퍼센트채널을 0.25 0.5 1 1.25 4개
(퍼센트채널 도 변수처리가능 ) 를 같이 사용할수있게 부탁드립니다
2 (38541)번의 당일진폭 국내선물 에서는 진폭글이 잘나오는데요
해외선물 유로선물 에서는 그냥 0.01 진폭으로나옵니다 해외선물의 뒷자리숫자가
소수점뒷자리 가 4 자리수자여서 그런것같습니다
제가 초보라서 수정된식을 부탁드립니다
항시 애써주시는 담당자님의 무궁한 발전을 기원합니다
감사합니다
2015-10-30
219
글번호 91897
답변완료
안녕하세요 . 수식 부탁드립니다
1
위 그림에서 macdv 가 기준선 0 아래에서 macds와 우상향 크로스후
macdv 가 기준선 0을 우상향 돌파시 매수
청산은 macdv가 macds 가 우하향 크로스일때 ..
식을 알고 싶습니다
2
아래 조건식을 사용중인데 ,,,
기술적 지표는 틱봉을 사용하고 . 참조데이터는 분봉이다보니
시간차에 의해 진입이 안되는 현상이 있어요 ...
그래서 시간을 5분안에 기술적 지표와 원하는 참조데이터 가 모두 만족 조건이 될 시에 진입하는 조건식을 알고 싶습니다 .
늘 감사합니다
Cond1 = False;
Cond2 = False;
Cond1 = #Ma300 > Ma400
#And Ma150 > Ma150[1] ;
#And Close >=Ma150[1]
#and Close >= MA150
crossup(stok,stod)
and stok > stod
#and stok > stok[1] ;
#and stok > 20
#and Close >= DayOpen
#and macdv >= macdv[1]
#and macdv >= macds
and macdv >= 0 ;
Cond2 = #Ma300 < Ma400
#And Ma150 < Ma150[1] ;
#And Close <= Ma150[1]
#and Close <= MA150
CrossDown(stok,stod)
and stok < stod
#and stok < stok[1] ;
#and stok < 80
#and Close <= DayOpen
#and macdv <= macdv[1]
#and macdv <= macds
and macdv <= 0 ;
Condition1 = MarketPosition != 1
#and (stime < 120000 or stime >= 151500)
#and data2(C) > 0
and data2(C > O)
#and data3(C) > 0
#and data3(C > O)
#and data4(C) > 0
and data4(C > O)
#and data5(C) > 0
#and data5(C > O)
#and data6(C > O)
#and data7(C > O)
and Cond1 == true ;
2015-10-30
252
글번호 91896
답변완료
수식 수정 부탁드립니다
수식 수정 2가지 입니다
(1)아래 식을 적용해본 결과
천정에서 -40,-80,...선이 완료된 후에는
바닥에서 +40,+80,...선이 출력되는 방식입니다
천정에서 -40,-80,...선과
바닥에서 +40,+80,...선이 번갈아 출력되지 않고
하나의 면적에 천정 지지선과 바닥 저항선이 동시에 출력되는 방식으로 수정 부탁드립니다
그리고 -40 글자는 blue, +40 글자는 red 색깔로 표시하는 수식도 추가부탁드립니다
감사합니다
----------------------------------------------------------------
input : N(40);
var : HH(0),LL(0),T(0),HD(0),HT(0),LD(0),LT(0),HL(0),LH(0);
var : Tx1(0),tx2(0),tx3(0),tx4(0),tx5(0);
var : tx6(0),tx7(0),tx8(0),tx9(0),Tx10(0);
if bdate != bdate[1] then{
T = 0;
HH = H;
LL = L;
}
if H > HH and Bdate == Bdate[1] Then{
T = 1;
HH = H;
Condition1 = false;
Condition2 = false;
Condition3 = false;
Condition4 = false;
Condition5 = false;
Condition6 = false;
Condition7 = false;
Condition8 = false;
Condition9 = false;
}
if L < LL and Bdate == Bdate[1] Then{
T = -1;
LL = L;
Condition1 = false;
Condition2 = false;
Condition3 = false;
Condition4 = false;
Condition5 = false;
Condition6 = false;
Condition7 = false;
Condition8 = false;
Condition9 = false;
}
if T == 1 Then{
var1 = dayhigh-PriceScale*(N*1);
var2 = dayhigh-PriceScale*(N*2);
var3 = dayhigh-PriceScale*(N*3);
var4 = dayhigh-PriceScale*(N*4);
var5 = dayhigh-PriceScale*(N*5);
var6 = dayhigh-PriceScale*(N*6);
var7 = dayhigh-PriceScale*(N*7);
var8 = dayhigh-PriceScale*(N*8);
var9 = dayhigh-PriceScale*(N*9);
plot1(var1,"1",blue);
plot2(var2,"2",blue);
plot3(var3,"3",blue);
plot4(var4,"4",blue);
plot5(var5,"5",blue);
plot6(var6,"6",blue);
plot7(var7,"7",blue);
plot8(var8,"8",blue);
plot9(var9,"9",blue);
Text_Delete(tx1);
Text_Delete(tx2);
Text_Delete(tx3);
Text_Delete(tx4);
Text_Delete(tx5);
Text_Delete(tx6);
Text_Delete(tx7);
Text_Delete(tx8);
Text_Delete(tx9);
tx1 = Text_New(sdate,stime,var1,"-"+NumToStr(N*1,0));
tx2 = Text_New(sdate,stime,var2,"-"+NumToStr(N*2,0));
tx3 = Text_New(sdate,stime,var3,"-"+NumToStr(N*3,0));
tx4 = Text_New(sdate,stime,var4,"-"+NumToStr(N*4,0));
tx5 = Text_New(sdate,stime,var5,"-"+NumToStr(N*5,0));
tx6 = Text_New(sdate,stime,var6,"-"+NumToStr(N*6,0));
tx7 = Text_New(sdate,stime,var7,"-"+NumToStr(N*7,0));
tx8 = Text_New(sdate,stime,var8,"-"+NumToStr(N*8,0));
tx9 = Text_New(sdate,stime,var9,"-"+NumToStr(N*9,0));
if Condition1 == false and CrossDown(c,var1) Then{
tx10 = Text_New(sdate,stime,H,"-"+NumToStr(N*1,0));
Condition1 = true;
}
if Condition2 == false and CrossDown(c,var2) Then{
tx10 = Text_New(sdate,stime,H,"-"+NumToStr(N*2,0));
Condition1 = true;
}
if Condition3 == false and CrossDown(c,var3) Then{
tx10 = Text_New(sdate,stime,H,"-"+NumToStr(N*3,0));
Condition3 = true;
}
if Condition4 == false and CrossDown(c,var4) Then{
tx10 = Text_New(sdate,stime,H,"-"+NumToStr(N*4,0));
Condition4 = true;
}
if Condition5 == false and CrossDown(c,var5) Then{
tx10 = Text_New(sdate,stime,H,"-"+NumToStr(N*5,0));
Condition5 = true;
}
if Condition6 == false and CrossDown(c,var6) Then{
tx10 = Text_New(sdate,stime,H,"-"+NumToStr(N*6,0));
Condition6 = true;
}
if Condition7 == false and CrossDown(c,var7) Then{
tx10 = Text_New(sdate,stime,H,"-"+NumToStr(N*7,0));
Condition7 = true;
}
if Condition8 == false and CrossDown(c,var8) Then{
tx10 = Text_New(sdate,stime,H,"-"+NumToStr(N*8,0));
Condition8 = true;
}
if Condition9 == false and CrossDown(c,var9) Then{
tx10 = Text_New(sdate,stime,H,"-"+NumToStr(N*8,0));
Condition9 = true;
}
Text_SetStyle(tx1,2,2);
Text_SetStyle(tx2,2,2);
Text_SetStyle(tx3,2,2);
Text_SetStyle(tx4,2,2);
Text_SetStyle(tx5,2,2);
Text_SetStyle(tx6,2,2);
Text_SetStyle(tx7,2,2);
Text_SetStyle(tx8,2,2);
Text_SetStyle(tx9,2,2);
Text_SetStyle(tx10,2,2);
}
if T == -1 Then{
var1 = daylow+PriceScale*(N*1);
var2 = daylow+PriceScale*(N*2);
var3 = daylow+PriceScale*(N*3);
var4 = daylow+PriceScale*(N*4);
var5 = daylow+PriceScale*(N*5);
var6 = daylow+PriceScale*(N*6);
var7 = daylow+PriceScale*(N*7);
var8 = daylow+PriceScale*(N*8);
var9 = daylow+PriceScale*(N*9);
plot1(var1,"1",red);
plot2(var2,"2",red);
plot3(var3,"3",red);
plot4(var4,"4",red);
plot5(var5,"5",red);
plot6(var6,"6",red);
plot7(var7,"7",red);
plot8(var8,"8",red);
plot9(var9,"9",red);
Text_Delete(tx1);
Text_Delete(tx2);
Text_Delete(tx3);
Text_Delete(tx4);
Text_Delete(tx5);
Text_Delete(tx6);
Text_Delete(tx7);
Text_Delete(tx8);
Text_Delete(tx9);
tx1 = Text_New(sdate,stime,var1,"+"+NumToStr(N*1,0));
tx2 = Text_New(sdate,stime,var2,"+"+NumToStr(N*2,0));
tx3 = Text_New(sdate,stime,var3,"+"+NumToStr(N*3,0));
tx4 = Text_New(sdate,stime,var4,"+"+NumToStr(N*4,0));
tx5 = Text_New(sdate,stime,var5,"+"+NumToStr(N*5,0));
tx6 = Text_New(sdate,stime,var6,"+"+NumToStr(N*6,0));
tx7 = Text_New(sdate,stime,var7,"+"+NumToStr(N*7,0));
tx8 = Text_New(sdate,stime,var8,"+"+NumToStr(N*8,0));
tx9 = Text_New(sdate,stime,var9,"+"+NumToStr(N*9,0));
if Condition1 == false and Crossup(c,var1) Then{
tx10 = Text_New(sdate,stime,H,"+"+NumToStr(N*1,0));
Condition1 = true;
}
if Condition2 == false and Crossup(c,var2) Then{
tx10 = Text_New(sdate,stime,H,"+"+NumToStr(N*2,0));
Condition1 = true;
}
if Condition3 == false and Crossup(c,var3) Then{
tx10 = Text_New(sdate,stime,H,"+"+NumToStr(N*3,0));
Condition3 = true;
}
if Condition4 == false and Crossup(c,var4) Then{
tx10 = Text_New(sdate,stime,H,"+"+NumToStr(N*4,0));
Condition4 = true;
}
if Condition5 == false and Crossup(c,var5) Then{
tx10 = Text_New(sdate,stime,H,"+"+NumToStr(N*5,0));
Condition5 = true;
}
if Condition6 == false and Crossup(c,var6) Then{
tx10 = Text_New(sdate,stime,H,"+"+NumToStr(N*6,0));
Condition6 = true;
}
if Condition7 == false and Crossup(c,var7) Then{
tx10 = Text_New(sdate,stime,H,"+"+NumToStr(N*7,0));
Condition7 = true;
}
if Condition8 == false and Crossup(c,var8) Then{
tx10 = Text_New(sdate,stime,H,"+"+NumToStr(N*8,0));
Condition8 = true;
}
if Condition9 == false and Crossup(c,var9) Then{
tx10 = Text_New(sdate,stime,H,"+"+NumToStr(N*8,0));
Condition9 = true;
}
Text_SetStyle(tx1,2,2);
Text_SetStyle(tx2,2,2);
Text_SetStyle(tx3,2,2);
Text_SetStyle(tx4,2,2);
Text_SetStyle(tx5,2,2);
Text_SetStyle(tx6,2,2);
Text_SetStyle(tx7,2,2);
Text_SetStyle(tx8,2,2);
Text_SetStyle(tx9,2,2);
Text_SetStyle(tx10,2,2);
}
------------------------------------------
(2)
아래식은 p1과 p2 크로스 시점에 진입식입니다
아래식을
p1과 p2 골든 크로스 가격을 현재가가 골든크로스 하거나 터치할때 매수
p1과 p2 데드 크로스 가격을 현재가가 데드크로스 하거나 터치할때 매도
진입식으로 수정 부탁드립니다
감사합니다
var:p1(0),p2(0);
p1=ma(c,10)
p2=ma(c,20)
if Crossup( p1,p2)
then{
buy();
}
if CrossDown( p1,p2)
then{
sell();
}
2015-11-01
334
글번호 91895
답변완료
시스템식 검토 부탁드립니다.
이평보정계수와 시장보정계수가 제대로 적용되지 않아 검토 부탁 드립니다.
그림1)에서 보듯이 120일 이동평균선이 우하향하는 조건이므로 이때 그림2) 처럼 이평보정계수(5)가 적용되어 기존 10:10 엔벨로프 하단선 부근에서 1차매수하던 것을 15:15 엔벨로프 하단선 부근에서 1차매수 신호가 발생되어야 하는데, 그림과 같이 적용이 되지 않네요..
하지만, 그림3)은 갭하락(5)로 설정했을때 이평보정계수가 제대로 적용된 경우입니다.
그림3)에 갭하락(4)로 설정했을 경우에는 120이평 조건과 갭하락 조건 두조건이 모두 만족하여 두가지 보정계수가 적용되므로 20:20 엔벨로프 하단선 부근에서 1차매수 신호가 발생하므로 현재의 차트에서는 1차매수 신호가 발생되지 말아야 하는데, 신호가 발생했습니다.
검토 부탁드립니다.
현재 시스템식은 다음과 같습니다.
----------------------------------------------------------------------------------------
input : 전략식시작일자(20151028), 전략식시작시간(090000), 전략총매수금액(5000);
input : 전략식종료일자(20151231);
input : 갭하락(5), 시장보정계수(5),일봉이평기간(120),이평보정계수(5);
input : P(10), 매수위치1차(10), 매수위치2차(7), 매수위치3차(14);
input : 매수위치보정(1);
input : 매도위치1차(7), 매도위치2차(14);
input : 매수비중1차(30), 매수비중2차(35), 매수비중3차(35);
input : 매도비중1차(50), 매도비중2차(50);
input : 전략식진입횟수(100);
input : 타점보유일수(5);
var : sum(0),mav(0),cnt(0),eup(0),edn(0),Didx(0),LatestEntryDidx(0),Ecnt(0);
var : TimeCond(false),Xcond1(false),Xcond2(false),Loss(0),LatestEntrylow(0);
var : Period(0),매수1차(0);
var : cum1(0),cum2(0),ma1(0),ma2(0);
# 일자수 계산
if date != date[1] Then
Didx = Didx+1;
# 일봉 120이평 계산(전일기준,전전일기준)
cum1 = 0;
cum2 = 0;
for cnt = 1 to 일봉이평기간{
cum1 = cum1+DayClose(cnt);
cum2 = cum2+DayClose(cnt+1);
}
# 전일기준 일봉 120일이평
ma1 = cum1/일봉이평기간;
# 전전일기준 일봉 120일이평
ma2 = cum2/일봉이평기간;
#기본값은 기간은 P, %는 매수위치1차
Period = P;
매수1차 = 매수위치1차;
#갭하락이면
#기간은 기존Period값+시장보정계수
#%는 기존 매수1차값에 + 시장보정계수
if dayopen < DayClose(1)*(1-갭하락) Then{
Period = Period + 시장보정계수;
매수1차 = 매수1차 + 시장보정계수;
}
#이평하락이면
#기간은 기존Period값+이평보정계수
#%는 기존 매수1차값에 + 이평보정계수
if ma1 < ma2 Then{
Period = Period + 이평보정계수;
매수1차 = 매수1차 + 이평보정계수;
}
#당일포함 일봉 Period개의 종가를 누적
sum = 0;
for cnt = 0 to Period-1{
sum = sum+DayClose(cnt);
}
#누적값을 Period로 나누어 평균값 산출
mav = sum/Period;
#상단계산
Eup = mav+mav*(매수1차/100);
#하단계산
Edn = mav-mav*(매수1차/100);
#지정일 지정시간이 되면 TimeCond는 True(그전에는 false)
if sdate == 전략식시작일자 and (stime == 전략식시작시간 or (stime > 전략식시작시간 and stime[1] < 전략식시작시간 )) then
TimeCond = true;
if sdate > 전략식종료일자 Then
TimeCond = false;
#TimeCond가 True가 된 후
if TimeCond == true then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "1차매수" Then
Ecnt = Ecnt+1;
#무포지션 상태에서 매수위치1차에 도달하면 매수
if MarketPosition == 0 and Ecnt < 전략식진입횟수 Then
buy("1차매수",atlimit,Edn*(1+매수위치보정/100),Floor((전략총매수금액*10000/c)*(매수비중1차/100)));
#첫매수이후
if MarketPosition == 1 Then{
#최근 진입시점의 일자수 저장
if CurrentContracts > CurrentContracts[1] Then{
LatestEntryDidx = Didx;
LatestEntrylow = L;
}
#1차매수 발생 후 매수위치2차에 도달하면 매수
if MaxEntries == 1 Then
buy("2차매수",atlimit,Edn[BarsSinceEntry]*(1-매수위치2차/100),Floor((전략총매수금액*10000/c)*(매수비중2차/100)));
#1차매수 발생 후 매수위치3차에 도달하면 매수
if MaxEntries == 2 Then
buy("3차매수",atlimit,Edn[BarsSinceEntry]*(1-매수위치3차/100),Floor((전략총매수금액*10000/c)*(매수비중3차/100)));
#1차매도가 한번 발생하면 더이상 발생못하도록 Xcond1은 true
if LatestExitName(0) == "1차매도" then
Xcond1 = true;
#2차매도가 한번 발생하면 더이상 발생못하도록 Xcond2는 true
if LatestExitName(0) == "2차매도" then
Xcond2 = true;
#Xcond1이 false일때
#진입이후 최저가에서 매도위치1차 만큼 상승하면 일부 청산
if Xcond1 == false Then
exitlong("1차매도",Atlimit,lowest(L,BarsSinceEntry)*(1+매도위치1차/100),"",Floor(MaxContracts*(매도비중1차/100)),1);
#Xcond2가 false일
#진입이후 최저가에서 매도위치2차 만큼 상승하면 전량청산
if Xcond2 == false Then
exitlong("2차매도",Atlimit,lowest(L,BarsSinceEntry)*(1+매도위치2차/100));
#최근 진입후 3일이상 경과(현재 일자수가 최근진입시점의 일자수보다 3이상증가)
if Didx >= LatestEntryDidx+타점보유일수 and Xcond1 == false and CurrentContracts == CurrentContracts[1] Then{
#최근 진입이후 3일되었을때의 최근진입일 포함3일 최저가 계산
if date != date[1] and Didx == LatestEntryDidx[BarsSinceEntry]+3 Then{
Loss = daylow(1);
for cnt = 1 to 타점보유일수 {
if daylow(cnt) < Loss Then
Loss = daylow(cnt);
}
}
#Loss값 이하로 가격하락하면 전량 청산
exitlong("손절",AtStop,Loss);
}
#최종 매수일 포함 3일경과되면 다음날 시가에 매도
if Didx == LatestEntryDidx+(타점보유일수-1) and stime == 150000 Then{
exitlong("익절2",AtMarket);
}
# 1차매도가 발생한 상황
# 가장 최근 진입일의 당일최저가보다 낮은 시세 발생하면 전량청산
# if L < LatestEntrylow and Xcond1 == false Then
# LatestEntrylow = L;
# if Xcond1 == true and CurrentContracts == CurrentContracts[1] Then{
# exitlong("익절1",AtStop,LatestEntrylow);
# }
}
else{ #매수포지션이 아니면 false로 초기화
Xcond1 = false;
Xcond2 = false;
}
}
2015-10-29
265
글번호 91894
회원 님에 의해서 삭제되었습니다.
2015-10-29
1
글번호 91893