커뮤니티
로직부탁...
2011-06-10 15:20:57
580
글번호 39619
다음과 같은 거래를 그 아래와 같이 수식 작성해 보았는데 의도된 대로 잘 안됩니다.
수정부탁합니다.
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);
}
}
답변 1
예스스탁 예스스탁 답변
2011-06-10 16:47:07
안녕하세요
예스스탁입니다.
아래와 같이 수정하셔야 합니다.
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);
}
}
즐거운 하루되세요
> 송사범 님이 쓴 글입니다.
> 제목 : 로직부탁...
> 다음과 같은 거래를 그 아래와 같이 수식 작성해 보았는데 의도된 대로 잘 안됩니다.
수정부탁합니다.
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);
}
}
다음글
이전글