커뮤니티

10081 질문 보완질문입니다.

프로필 이미지
송사범
2009-03-18 09:32:24
826
글번호 21004
제가 아래 조건식에 대하여 그 아래 로직을 작성해 보았는데 잘 실행되지 않습니다. 수정,보완부탁드립니다. (메일(aceace77@hanmail.net)로 답글 부탁드립니다.) <조건식> 옵션 1분봉 매수전용 로직입니다. 총 매매회수는 2회로 제한. <매수식> (1) 9시에 첫봉이 양봉이면 종가에 1개 매수. (2) 9시1분에 첫봉이 양봉이고, 종가가 첫봉 시가보다 크면 1개 매수. (3) 9시2분에서 9시20분 사이에 첫봉이 양봉이고, 종가가 양봉이면서 첫봉 종가 보다 크면 1개 매수. (4) 9시1분에서 9시20분 사이에 첫봉이 음봉이고, 종가가 양봉이면서 첫봉 종가+0.02보다 크면 1개 매수. <매수청산식> 위 각 매수식에 대하여 아래 로직 각 매수청산이 적용되도록 하고자 합니다. <문제점> (1) 제가 원하는 것은 "매수1"만 따져 아래 매수청산식 조건대로 청산이 이뤄지고, "매수2"만 따져 아래 매수청산식 조건대로 청산이 이뤄지고, "매수3"만 따져 아래 매수청산식 조건대로 청산이 이뤄지고, "매수4"만 따져 아래 매수청산식 조건대로 청산이 이뤄지기를 원하는데 도무지 그렇게 되지 않네요. 매수평균가를 기준으로 이익보존 등이 이뤄지는 것 같기도 하고 말이죠... (2) 그리고 피라미딩 설정은 또 어떻게 해야 할까요? 피라미딩 설정을 모든 진입신호 허용을 하니까 총 매매회수 제한 2회에 상관없이 그 이상 진입이 되고, 다른 진입신호만 허용해도 “매수1”,“매수2”,“매수3”까지 총 3회까지 매수진입되는 경우가 있는데 어떻게 설정해야 하나요? --------------------------------------------------------------------------------- input : ts(8),ts2(7),ts3(5),fl(10),fl2(15),fl3(20),sp(8),maxbar(60); var : maxp(0),count(0),cnt(0); count = 0; for cnt = 0 to 10{ if sdate == EntryDate(cnt) Then count = count +1; } if sTime==090000 Then{ var2=Close+0.02; var3=Close; var4=Open; } if count<2 Then{ If sTime==090000 and var3>var4 Then Buy("매수1",onclose,def,1); if sTime==090100 and var3>var4 and c>var4 Then buy("매수2",onclose,def,1); if stime>=090200 and stime<=092000 and var3>var4 and C>O and C>var3 Then buy("매수3",onclose,def,1); if stime>=090100 and stime<=092000 and var3<var4 and C>O and C>var2 Then buy("매수4",onclose,def,1); } MaxP = Highest(High, BarsSinceEntry + 1); If IsEntryName("매수1") Then { If MaxP >= (EntryPrice * (1+fl/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then ExitLong("이익보존1", Atstop, MaxP *(1-ts/100),def,1); If MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존2", Atstop, MaxP *(1-ts2/100),def,1); If MaxP >= (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존3", Atstop, MaxP *(1-ts3/100),def,1); If MaxBar <= BarsSinceEntry + 1 And MaxP < EntryPrice * (1 + fl / 100) Then ExitLong("기간청산1", Atmarket,def); ExitLong("손절매1", Atstop, EntryPrice*(1-sp/100),def,1); } If IsEntryName("매수2") Then { If MaxP >= (EntryPrice * (1+fl/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then ExitLong("이익보존21", Atstop, MaxP *(1-ts/100),def,1); If MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존22", Atstop, MaxP *(1-ts2/100),def,1); If MaxP >= (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존23", Atstop, MaxP *(1-ts3/100),def,1); If MaxBar <= BarsSinceEntry + 1 And MaxP < EntryPrice * (1 + fl / 100) Then ExitLong("기간청산2", Atmarket,def); ExitLong("손절매21", Atstop, EntryPrice*(1-sp/100),def,1); } If IsEntryName("매수3") Then { If MaxP >= (EntryPrice * (1+fl/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then ExitLong("이익보존31", Atstop, MaxP *(1-ts/100),def,1); If MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존32", Atstop, MaxP *(1-ts2/100),def,1); If MaxP >= (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존33", Atstop, MaxP *(1-ts3/100),def,1); If MaxBar <= BarsSinceEntry + 1 And MaxP < EntryPrice * (1 + fl / 100) Then ExitLong("기간청산3", Atmarket,def); ExitLong("손절매31", Atstop, EntryPrice*(1-sp/100),def,1); } If IsEntryName("매수4") Then { If MaxP >= (EntryPrice * (1+fl/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then ExitLong("이익보존41", Atstop, MaxP *(1-ts/100),def,1); If MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존42", Atstop, MaxP *(1-ts2/100),def,1); If MaxP >= (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존43", Atstop, MaxP *(1-ts3/100),def,1); If MaxBar <= BarsSinceEntry + 1 And MaxP < EntryPrice * (1 + fl / 100) Then ExitLong("기간청산4", Atmarket,def); ExitLong("손절매41", Atstop, EntryPrice*(1-sp/100),def,1); } ---------------------------------------------------------------------------------
시스템
답변 1
프로필 이미지

브라보88

2009-03-18 11:40:03

> 송사범 님이 쓴 글입니다. > 제목 : 10081 질문 보완질문입니다. > 제가 아래 조건식에 대하여 그 아래 로직을 작성해 보았는데 잘 실행되지 않습니다. 수정,보완부탁드립니다. (메일(aceace77@hanmail.net)로 답글 부탁드립니다.) <조건식> 옵션 1분봉 매수전용 로직입니다. 총 매매회수는 2회로 제한. <매수식> (1) 9시에 첫봉이 양봉이면 종가에 1개 매수. (2) 9시1분에 첫봉이 양봉이고, 종가가 첫봉 시가보다 크면 1개 매수. (3) 9시2분에서 9시20분 사이에 첫봉이 양봉이고, 종가가 양봉이면서 첫봉 종가 보다 크면 1개 매수. (4) 9시1분에서 9시20분 사이에 첫봉이 음봉이고, 종가가 양봉이면서 첫봉 종가+0.02보다 크면 1개 매수. <매수청산식> 위 각 매수식에 대하여 아래 로직 각 매수청산이 적용되도록 하고자 합니다. <문제점> (1) 제가 원하는 것은 "매수1"만 따져 아래 매수청산식 조건대로 청산이 이뤄지고, "매수2"만 따져 아래 매수청산식 조건대로 청산이 이뤄지고, "매수3"만 따져 아래 매수청산식 조건대로 청산이 이뤄지고, "매수4"만 따져 아래 매수청산식 조건대로 청산이 이뤄지기를 원하는데 도무지 그렇게 되지 않네요. 매수평균가를 기준으로 이익보존 등이 이뤄지는 것 같기도 하고 말이죠... (2) 그리고 피라미딩 설정은 또 어떻게 해야 할까요? 피라미딩 설정을 모든 진입신호 허용을 하니까 총 매매회수 제한 2회에 상관없이 그 이상 진입이 되고, 다른 진입신호만 허용해도 “매수1”,“매수2”,“매수3”까지 총 3회까지 매수진입되는 경우가 있는데 어떻게 설정해야 하나요? --------------------------------------------------------------------------------- input : ts(8),ts2(7),ts3(5),fl(10),fl2(15),fl3(20),sp(8),maxbar(60); var : maxp(0),count(0),cnt(0); count = 0; for cnt = 0 to 10{ if sdate == EntryDate(cnt) Then count = count +1; } if sTime==090000 Then{ var2=Close+0.02; var3=Close; var4=Open; } if count<2 Then{ If sTime==090000 and var3>var4 Then Buy("매수1",onclose,def,1); if sTime==090100 and var3>var4 and c>var4 Then buy("매수2",onclose,def,1); if stime>=090200 and stime<=092000 and var3>var4 and C>O and C>var3 Then buy("매수3",onclose,def,1); if stime>=090100 and stime<=092000 and var3<var4 and C>O and C>var2 Then buy("매수4",onclose,def,1); } MaxP = Highest(High, BarsSinceEntry + 1); If IsEntryName("매수1") Then { If MaxP >= (EntryPrice * (1+fl/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then ExitLong("이익보존1", Atstop, MaxP *(1-ts/100),def,1); If MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존2", Atstop, MaxP *(1-ts2/100),def,1); If MaxP >= (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존3", Atstop, MaxP *(1-ts3/100),def,1); If MaxBar <= BarsSinceEntry + 1 And MaxP < EntryPrice * (1 + fl / 100) Then ExitLong("기간청산1", Atmarket,def); ExitLong("손절매1", Atstop, EntryPrice*(1-sp/100),def,1); } If IsEntryName("매수2") Then { If MaxP >= (EntryPrice * (1+fl/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then ExitLong("이익보존21", Atstop, MaxP *(1-ts/100),def,1); If MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존22", Atstop, MaxP *(1-ts2/100),def,1); If MaxP >= (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존23", Atstop, MaxP *(1-ts3/100),def,1); If MaxBar <= BarsSinceEntry + 1 And MaxP < EntryPrice * (1 + fl / 100) Then ExitLong("기간청산2", Atmarket,def); ExitLong("손절매21", Atstop, EntryPrice*(1-sp/100),def,1); } If IsEntryName("매수3") Then { If MaxP >= (EntryPrice * (1+fl/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then ExitLong("이익보존31", Atstop, MaxP *(1-ts/100),def,1); If MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존32", Atstop, MaxP *(1-ts2/100),def,1); If MaxP >= (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존33", Atstop, MaxP *(1-ts3/100),def,1); If MaxBar <= BarsSinceEntry + 1 And MaxP < EntryPrice * (1 + fl / 100) Then ExitLong("기간청산3", Atmarket,def); ExitLong("손절매31", Atstop, EntryPrice*(1-sp/100),def,1); } If IsEntryName("매수4") Then { If MaxP >= (EntryPrice * (1+fl/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then ExitLong("이익보존41", Atstop, MaxP *(1-ts/100),def,1); If MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존42", Atstop, MaxP *(1-ts2/100),def,1); If MaxP >= (EntryPrice * (1+fl3/100)) Then ExitLong("이익보존43", Atstop, MaxP *(1-ts3/100),def,1); If MaxBar <= BarsSinceEntry + 1 And MaxP < EntryPrice * (1 + fl / 100) Then ExitLong("기간청산4", Atmarket,def); ExitLong("손절매41", Atstop, EntryPrice*(1-sp/100),def,1); } ---------------------------------------------------------------------------------