커뮤니티
수식부탁
2011-06-13 18:10:09
652
글번호 39721
제가 19072번으로 아래와 같은 질문을 올렸고 그 아래와 같은 답글을 잘 받았습니다.
그런데 오늘 옵션창 2개에서 매매가 발생하였습니다. 제가 의도했던 대로라면 옵션창 1개에서만 매매가 이뤄져야 하는데 무엇이 잘못되었는지 도무지 알 수가 없습니다.
개인적인 생각으로는
"If data3(sTime>092000 and sTime<=100000 and c<1.5 and BarIndex>=Var5) and sdate == var6 Then
cond3=True;“부분을
"cond3==false" 로 하면 "c<1.5" 부분만이 아니라 “sTime>092000 and sTime<=100000“ 부분이나 ”BarIndex>=Var5“ 부분, ”sdate == var6“ 부분도 모두 false가 되어 제가 의도했던 ”9시20분부터 10시까지의 사이에 BarIndex가 Var5 이후 c가 15만원 미만이었던 적이 없는 경우“라는 의미와는 뜻이 전혀 달라지는 것이 아닌가 싶습니다.
보완수정부탁드립니다...
@질문@---------------------------------------
다음과 같은 거래를 그 아래와 같이 수식 작성해 보았는데 의도된 대로 잘 안됩니다.
수정부탁합니다.
data2,data3 차트까지 들어간 옵션창 3개를 띄워놓고 매매합니다.
<매수식>
공통매수조건 - (1) 9시1분봉과 9시20분봉 고가를 초과하면 매수.
(2) 현재가가 11만원 초과, 15만원 이하일 것.
첫번째 매수식 - 현재가가 data2와 data3보다 크면 매수하라.
두번째 매수식 - 현재가가 data2 현재가 보다는 크고 data3 현재가 보다는 작을 때, data3 종가가 9시1분봉 고가 및 9시20분봉 고가를 초과한 이후로부터 15만원 미만이었던 적이 없을 경우 매수하라.
세번째 매수식 - 현재가가 data2 현재가와 data3 현재가 보다 작을 때, data3 종가가 9시1분봉 고가 및 9시20분봉 고가를 초과한 이후로부터 15만원 미만이었던 적이 없을 경우 매수하라.
<매수청산식>
매수청산식은 대강 맞는 것 같은데 한번 검토 부탁합니다.
---------------------------------------------------------------------------------
input : ts1(8),ts2(6.5),ts3(5),fl1(10),fl2(20),fl3(100),sp1(8),sp2(10),sp3(11),sp4(12),sp5(13), maxbar(60);
Var : maxp(0),count(0),cnt(0);
Var : cond3(False,data3);
count = 0;
for cnt = 0 to 10{
if sdate == EntryDate(cnt) Then
count = count +1;
}
if sTime==090100 Then
Var1=H;
Var2=data3(H);
if sTime==092000 Then
Var3=H;
Var4=data3(H);
If Data3(c)>var2 and Data3(c)>var4 Then
var5=BarIndex;
If Data3(sDate!=sDate[1]) Then
cond3=False;
If data3(sTime>092000 and sTime<=100000 and c<1.5 and BarIndex>=Var5) Then
cond3=True;
If MarketPosition() == 0 and count<1 and stime>092000 and stime<=100000 Then {
If c>1.1 and c<=1.5 Then {
If c>Var1 and c>Var3 and c>o and c>data2(c) and c>data3(c) Then
buy("매수3",onclose,DEF,3);
If c>Var1 and c>var3 and c>o and c>data2(c) and c<data3(c) and cond3==False Then
buy("매수3-1",onclose,DEF,3);
If c>Var1 and c>var3 and c>o and c<data2(c) and c<data3(c) and cond3==False Then
buy("매수3-2",onclose,DEF,3);
}
}
MaxP = Highest(H, BarsSinceEntry + 1);
If EntryName == "매수3" or EntryName == "매수3-1" or EntryName == "매수3-2" Then {
If marketPosition() == 1 Then {
if MaxP >= (EntryPrice * (1+fl1/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then
ExitLong("이익보존3", Atstop, MaxP *(1-ts1/100),def,1);
if MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then
ExitLong("이익보존3-1", Atstop, MaxP *(1-ts2/100),def,1);
If MaxP >= (EntryPrice * (1+fl3/100)) Then
ExitLong("이익보존3-2", Atstop, MaxP *(1-ts3/100),def,3);
}
If marketPosition() == 1 Then {
ExitLong("손절매3", Atstop, EntryPrice*(1-sp1/100),def,1);
ExitLong("손절매3-1", Atstop, EntryPrice*(1-sp3/100),def,1);
ExitLong("손절매3-2", Atstop, EntryPrice*(1-sp4/100),def,3);
}
If marketPosition() == 1 Then {
If MaxBar<=BarsSinceEntry+1 And MaxP<EntryPrice*(1+fl1/100) Then
ExitLong("기간청산3", Atmarket);
}
}
@답글@---------------------------------------
안녕하세요
예스스탁입니다.
아래와 같이 수정하셔야 합니다.
if문이 만족할때 실행해야 되는 실행문이 여러개 일경우 {}로 묶어주셔야 하며
var5에 값이 9시 20분 이후에 저장되어야 하며
var6으로 날짜를 저장하여 당일날짜와 같은 날 저장된것인지를
판단하도록 했습니다.
input : ts1(8),ts2(6.5),ts3(5),fl1(10),fl2(20),fl3(100),sp1(8),sp2(10),sp3(11),sp4(12),sp5(13), maxbar(60);
Var : maxp(0),count(0),cnt(0);
Var : cond3(False,data3);
count = 0;
for cnt = 0 to 10{
if sdate == EntryDate(cnt) Then
count = count +1;
}
if sTime==090100 Then{
Var1=H;
Var2=data3(H);
}
if sTime==092000 Then{
Var3=H;
Var4=data3(H);
}
If Data3(c)>var2 and Data3(c)>var4 and stime > 92000 Then{
var5 = BarIndex;
var6 = sdate;
}
If Data3(sDate!=sDate[1]) Then
cond3=False;
If data3(sTime>092000 and sTime<=100000 and c<1.5 and BarIndex>=Var5) and sdate == var6 Then
cond3=True;
If MarketPosition() == 0 and count<1 and stime>092000 and stime<=100000 Then {
If c>1.1 and c<=1.5 and c > Var1 and c > Var3 and c>o Then {
If c>data2(c) and c>data3(c) Then
buy("매수3",onclose,DEF,3);
If c>data2(c) and c<data3(c) and cond3==False Then
buy("매수3-1",onclose,DEF,3);
If c<data2(c) and c<data3(c) and cond3==False Then
buy("매수3-2",onclose,DEF,3);
}
}
MaxP = Highest(H, BarsSinceEntry + 1);
If EntryName == "매수3" or EntryName == "매수3-1" or EntryName == "매수3-2" Then {
If marketPosition() == 1 Then {
if MaxP >= (EntryPrice * (1+fl1/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then
ExitLong("이익보존3", Atstop, MaxP *(1-ts1/100),def,1);
if MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then
ExitLong("이익보존3-1", Atstop, MaxP *(1-ts2/100),def,1);
If MaxP >= (EntryPrice * (1+fl3/100)) Then
ExitLong("이익보존3-2", Atstop, MaxP *(1-ts3/100),def,3);
}
If marketPosition() == 1 Then {
ExitLong("손절매3", Atstop, EntryPrice*(1-sp1/100),def,1);
ExitLong("손절매3-1", Atstop, EntryPrice*(1-sp3/100),def,1);
ExitLong("손절매3-2", Atstop, EntryPrice*(1-sp4/100),def,3);
}
If marketPosition() == 1 Then {
If MaxBar<=BarsSinceEntry+1 And MaxP<EntryPrice*(1+fl1/100) Then
ExitLong("기간청산3", Atmarket);
}
}
답변 1
예스스탁 예스스탁 답변
2011-06-14 13:38:57
> 송사범 님이 쓴 글입니다.
> 제목 : 수식부탁
> 제가 19072번으로 아래와 같은 질문을 올렸고 그 아래와 같은 답글을 잘 받았습니다.
그런데 오늘 옵션창 2개에서 매매가 발생하였습니다. 제가 의도했던 대로라면 옵션창 1개에서만 매매가 이뤄져야 하는데 무엇이 잘못되었는지 도무지 알 수가 없습니다.
개인적인 생각으로는
"If data3(sTime>092000 and sTime<=100000 and c<1.5 and BarIndex>=Var5) and sdate == var6 Then
cond3=True;“부분을
"cond3==false" 로 하면 "c<1.5" 부분만이 아니라 “sTime>092000 and sTime<=100000“ 부분이나 ”BarIndex>=Var5“ 부분, ”sdate == var6“ 부분도 모두 false가 되어 제가 의도했던 ”9시20분부터 10시까지의 사이에 BarIndex가 Var5 이후 c가 15만원 미만이었던 적이 없는 경우“라는 의미와는 뜻이 전혀 달라지는 것이 아닌가 싶습니다.
보완수정부탁드립니다...
@질문@---------------------------------------
다음과 같은 거래를 그 아래와 같이 수식 작성해 보았는데 의도된 대로 잘 안됩니다.
수정부탁합니다.
data2,data3 차트까지 들어간 옵션창 3개를 띄워놓고 매매합니다.
<매수식>
공통매수조건 - (1) 9시1분봉과 9시20분봉 고가를 초과하면 매수.
(2) 현재가가 11만원 초과, 15만원 이하일 것.
첫번째 매수식 - 현재가가 data2와 data3보다 크면 매수하라.
두번째 매수식 - 현재가가 data2 현재가 보다는 크고 data3 현재가 보다는 작을 때, data3 종가가 9시1분봉 고가 및 9시20분봉 고가를 초과한 이후로부터 15만원 미만이었던 적이 없을 경우 매수하라.
세번째 매수식 - 현재가가 data2 현재가와 data3 현재가 보다 작을 때, data3 종가가 9시1분봉 고가 및 9시20분봉 고가를 초과한 이후로부터 15만원 미만이었던 적이 없을 경우 매수하라.
<매수청산식>
매수청산식은 대강 맞는 것 같은데 한번 검토 부탁합니다.
---------------------------------------------------------------------------------
input : ts1(8),ts2(6.5),ts3(5),fl1(10),fl2(20),fl3(100),sp1(8),sp2(10),sp3(11),sp4(12),sp5(13), maxbar(60);
Var : maxp(0),count(0),cnt(0);
Var : cond3(False,data3);
count = 0;
for cnt = 0 to 10{
if sdate == EntryDate(cnt) Then
count = count +1;
}
if sTime==090100 Then
Var1=H;
Var2=data3(H);
if sTime==092000 Then
Var3=H;
Var4=data3(H);
If Data3(c)>var2 and Data3(c)>var4 Then
var5=BarIndex;
If Data3(sDate!=sDate[1]) Then
cond3=False;
If data3(sTime>092000 and sTime<=100000 and c<1.5 and BarIndex>=Var5) Then
cond3=True;
If MarketPosition() == 0 and count<1 and stime>092000 and stime<=100000 Then {
If c>1.1 and c<=1.5 Then {
If c>Var1 and c>Var3 and c>o and c>data2(c) and c>data3(c) Then
buy("매수3",onclose,DEF,3);
If c>Var1 and c>var3 and c>o and c>data2(c) and c<data3(c) and cond3==False Then
buy("매수3-1",onclose,DEF,3);
If c>Var1 and c>var3 and c>o and c<data2(c) and c<data3(c) and cond3==False Then
buy("매수3-2",onclose,DEF,3);
}
}
MaxP = Highest(H, BarsSinceEntry + 1);
If EntryName == "매수3" or EntryName == "매수3-1" or EntryName == "매수3-2" Then {
If marketPosition() == 1 Then {
if MaxP >= (EntryPrice * (1+fl1/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then
ExitLong("이익보존3", Atstop, MaxP *(1-ts1/100),def,1);
if MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then
ExitLong("이익보존3-1", Atstop, MaxP *(1-ts2/100),def,1);
If MaxP >= (EntryPrice * (1+fl3/100)) Then
ExitLong("이익보존3-2", Atstop, MaxP *(1-ts3/100),def,3);
}
If marketPosition() == 1 Then {
ExitLong("손절매3", Atstop, EntryPrice*(1-sp1/100),def,1);
ExitLong("손절매3-1", Atstop, EntryPrice*(1-sp3/100),def,1);
ExitLong("손절매3-2", Atstop, EntryPrice*(1-sp4/100),def,3);
}
If marketPosition() == 1 Then {
If MaxBar<=BarsSinceEntry+1 And MaxP<EntryPrice*(1+fl1/100) Then
ExitLong("기간청산3", Atmarket);
}
}
@답글@---------------------------------------
안녕하세요
예스스탁입니다.
아래와 같이 수정하셔야 합니다.
if문이 만족할때 실행해야 되는 실행문이 여러개 일경우 {}로 묶어주셔야 하며
var5에 값이 9시 20분 이후에 저장되어야 하며
var6으로 날짜를 저장하여 당일날짜와 같은 날 저장된것인지를
판단하도록 했습니다.
input : ts1(8),ts2(6.5),ts3(5),fl1(10),fl2(20),fl3(100),sp1(8),sp2(10),sp3(11),sp4(12),sp5(13), maxbar(60);
Var : maxp(0),count(0),cnt(0);
Var : cond3(False,data3);
count = 0;
for cnt = 0 to 10{
if sdate == EntryDate(cnt) Then
count = count +1;
}
if sTime==090100 Then{
Var1=H;
Var2=data3(H);
}
if sTime==092000 Then{
Var3=H;
Var4=data3(H);
}
If Data3(c)>var2 and Data3(c)>var4 and stime > 92000 Then{
var5 = BarIndex;
var6 = sdate;
}
If Data3(sDate!=sDate[1]) Then
cond3=False;
If data3(sTime>092000 and sTime<=100000 and c<1.5 and BarIndex>=Var5) and sdate == var6 Then
cond3=True;
If MarketPosition() == 0 and count<1 and stime>092000 and stime<=100000 Then {
If c>1.1 and c<=1.5 and c > Var1 and c > Var3 and c>o Then {
If c>data2(c) and c>data3(c) Then
buy("매수3",onclose,DEF,3);
If c>data2(c) and c<data3(c) and cond3==False Then
buy("매수3-1",onclose,DEF,3);
If c<data2(c) and c<data3(c) and cond3==False Then
buy("매수3-2",onclose,DEF,3);
}
}
MaxP = Highest(H, BarsSinceEntry + 1);
If EntryName == "매수3" or EntryName == "매수3-1" or EntryName == "매수3-2" Then {
If marketPosition() == 1 Then {
if MaxP >= (EntryPrice * (1+fl1/100)) and MaxP < (EntryPrice * (1+fl2/100)) Then
ExitLong("이익보존3", Atstop, MaxP *(1-ts1/100),def,1);
if MaxP >= (EntryPrice * (1+fl2/100)) and MaxP < (EntryPrice * (1+fl3/100)) Then
ExitLong("이익보존3-1", Atstop, MaxP *(1-ts2/100),def,1);
If MaxP >= (EntryPrice * (1+fl3/100)) Then
ExitLong("이익보존3-2", Atstop, MaxP *(1-ts3/100),def,3);
}
If marketPosition() == 1 Then {
ExitLong("손절매3", Atstop, EntryPrice*(1-sp1/100),def,1);
ExitLong("손절매3-1", Atstop, EntryPrice*(1-sp3/100),def,1);
ExitLong("손절매3-2", Atstop, EntryPrice*(1-sp4/100),def,3);
}
If marketPosition() == 1 Then {
If MaxBar<=BarsSinceEntry+1 And MaxP<EntryPrice*(1+fl1/100) Then
ExitLong("기간청산3", Atmarket);
}
}