커뮤니티
청산을 endtime으로 설정하였구요.. 추가로 음봉일때 청산할수 있는 수식좀 알려주세?
2018-10-23 02:34:53
217
글번호 122934
진입은 조건에 부합하면 진입은 설정했구요..
청산은 endtime에 일괄 청산으로 설정했는데요...
청산에 한 조건을 추가하고 싶어요... 30봉분으로 설정하였는데요...
청산조건
매수진입을 청산할때 양봉일때는 청산 하지 않고 다음 음봉일때 (또는 2회 연속 음봉일때 ) 청산
매도진입후 청산할때 음봉일때는 청산하지 않고 다음 양봉일때 (또는 2회 연속 양봉일때) 청산
할수 있는 수식좀 부탁합니다.
input : P1(-0.3),P2(0.8),P3(8),P4(-0.4),P5(0.4),p6(1000),starttime(223000),endtime(150000),P7(1.5),P8(0.8);
var : cnt(0),sum(0),sum1(0),mav(0),mav1(0),T(0),mav2(0),mav3(0);
var : sum3(0),Tcond(false);
Condition1 = MarketPosition == 0 and ExitDate(1) == sdate and
(IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) and
TimeToMinutes(stime) <= TimeToMinutes(ExitTime(1))+p6;
#설정
if sdate != sdate[1] then
SetStopEndofday(endtime);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
SetStopEndofday(0);#해제
}
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
if DayClose(P3) > 0 Then
{
sum = 0;
sum1 = 0;
for cnt = 0 to P3-1
{
sum = sum + DayClose(cnt);
sum1 = sum1 + DayClose(cnt+1);
}
mav = sum/P3;
mav1 = sum1/P3;
T = 0;
if mav > mav1 Then
T = 1;
if mav < mav1 Then
T = -1;
if T == 1 Then
mav2=p2 ;
if T == -1 Then
mav2=p5;
if T == 1 Then
mav3=p1 ;
if T == -1 Then
mav3=p4 ;
sum3 = 0;
for cnt = 1 to 20
{
sum3 = sum3 + (DayHigh(cnt)-DayLow(cnt));
}
value1 = sum3/20 ;
If MarketPosition == 0 and C >= (dayopen+value1*mav3) and C<C[1] and Condition1 == false Then
{
Buy("매수");
}
if MaxEntries == 1 and MarketPosition == 1 Then
{
buy("추가매수",atlimit,EntryPrice-P7);
}
If MarketPosition == 0 and C <= (dayopen-value1*mav2) and C>C[1] and Condition1 == false Then
{
sell("매도");
}
if MaxEntries == 1 and MarketPosition == -1 Then
{
Sell("추가매도",atlimit,EntryPrice+P8);
}
}
답변 2
예스스탁 예스스탁 답변
2018-10-23 14:00:54
안녕하세요
예스스탁입니다.
매수진입 후 N개봉 연속음봉이면청산,
매도진입 후 N개봉 연속양봉이면 청산되게 추가했습니다.
input : P1(-0.3),P2(0.8),P3(8),P4(-0.4),P5(0.4),p6(1000),starttime(223000),endtime(150000),P7(1.5),P8(0.8),N(2);
var : cnt(0),sum(0),sum1(0),mav(0),mav1(0),T(0),mav2(0),mav3(0);
var : sum3(0),Tcond(false);
Condition1 = MarketPosition == 0 and ExitDate(1) == sdate and
(IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) and
TimeToMinutes(stime) <= TimeToMinutes(ExitTime(1))+p6;
#설정
if sdate != sdate[1] then
SetStopEndofday(endtime);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
SetStopEndofday(0);#해제
}
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
if DayClose(P3) > 0 Then
{
sum = 0;
sum1 = 0;
for cnt = 0 to P3-1
{
sum = sum + DayClose(cnt);
sum1 = sum1 + DayClose(cnt+1);
}
mav = sum/P3;
mav1 = sum1/P3;
T = 0;
if mav > mav1 Then
T = 1;
if mav < mav1 Then
T = -1;
if T == 1 Then
mav2=p2 ;
if T == -1 Then
mav2=p5;
if T == 1 Then
mav3=p1 ;
if T == -1 Then
mav3=p4 ;
sum3 = 0;
for cnt = 1 to 20
{
sum3 = sum3 + (DayHigh(cnt)-DayLow(cnt));
}
value1 = sum3/20 ;
If MarketPosition == 0 and C >= (dayopen+value1*mav3) and C<C[1] and Condition1 == false Then
{
Buy("매수");
}
if MaxEntries == 1 and MarketPosition == 1 Then
{
buy("추가매수",atlimit,EntryPrice-P7);
}
If MarketPosition == 0 and C <= (dayopen-value1*mav2) and C>C[1] and Condition1 == false Then
{
sell("매도");
}
if MaxEntries == 1 and MarketPosition == -1 Then
{
Sell("추가매도",atlimit,EntryPrice+P8);
}
}
if MarketPosition == 1 and countif(C < O,N) == N Then
exitlong("bx");
if MarketPosition == -1 and countif(C > O,N) == N Then
ExitShort("sx");
즐거운 하루되세요
> 이형지 님이 쓴 글입니다.
> 제목 : 청산을 endtime으로 설정하였구요.. 추가로 음봉일때 청산할수 있는 수식좀 알려주세?
> 진입은 조건에 부합하면 진입은 설정했구요..
청산은 endtime에 일괄 청산으로 설정했는데요...
청산에 한 조건을 추가하고 싶어요... 30봉분으로 설정하였는데요...
청산조건
매수진입을 청산할때 양봉일때는 청산 하지 않고 다음 음봉일때 (또는 2회 연속 음봉일때 ) 청산
매도진입후 청산할때 음봉일때는 청산하지 않고 다음 양봉일때 (또는 2회 연속 양봉일때) 청산
할수 있는 수식좀 부탁합니다.
input : P1(-0.3),P2(0.8),P3(8),P4(-0.4),P5(0.4),p6(1000),starttime(223000),endtime(150000),P7(1.5),P8(0.8);
var : cnt(0),sum(0),sum1(0),mav(0),mav1(0),T(0),mav2(0),mav3(0);
var : sum3(0),Tcond(false);
Condition1 = MarketPosition == 0 and ExitDate(1) == sdate and
(IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) and
TimeToMinutes(stime) <= TimeToMinutes(ExitTime(1))+p6;
#설정
if sdate != sdate[1] then
SetStopEndofday(endtime);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
SetStopEndofday(0);#해제
}
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
if DayClose(P3) > 0 Then
{
sum = 0;
sum1 = 0;
for cnt = 0 to P3-1
{
sum = sum + DayClose(cnt);
sum1 = sum1 + DayClose(cnt+1);
}
mav = sum/P3;
mav1 = sum1/P3;
T = 0;
if mav > mav1 Then
T = 1;
if mav < mav1 Then
T = -1;
if T == 1 Then
mav2=p2 ;
if T == -1 Then
mav2=p5;
if T == 1 Then
mav3=p1 ;
if T == -1 Then
mav3=p4 ;
sum3 = 0;
for cnt = 1 to 20
{
sum3 = sum3 + (DayHigh(cnt)-DayLow(cnt));
}
value1 = sum3/20 ;
If MarketPosition == 0 and C >= (dayopen+value1*mav3) and C<C[1] and Condition1 == false Then
{
Buy("매수");
}
if MaxEntries == 1 and MarketPosition == 1 Then
{
buy("추가매수",atlimit,EntryPrice-P7);
}
If MarketPosition == 0 and C <= (dayopen-value1*mav2) and C>C[1] and Condition1 == false Then
{
sell("매도");
}
if MaxEntries == 1 and MarketPosition == -1 Then
{
Sell("추가매도",atlimit,EntryPrice+P8);
}
}
이형지
2018-10-23 22:39:03
최초 수식은 endtime에 전량 청산이였습니다.
그리고 원하는것은 endtime시간이 경과후 청산시 무조건 청산이 아니라
매수한것 청산할때 -->음봉으로 될때 청산하는것으로 변경 수식좀 알려쥇요~~
수식으로 주신거은 하루에 한번 청산에 위반됩니다. 저번에 추천한 수식은 시도때도없이 매매됩니다.
간단히 제가 원하는것은
이전 : endtime에 도달시 청산 --> 개선 : end time도달하더라도 30분봉이 양봉일때 청산
하는 식을 알려주세요~~~~
> 이형지 님이 쓴 글입니다.
> 제목 : 청산을 endtime으로 설정하였구요.. 추가로 음봉일때 청산할수 있는 수식좀 알려주세?
> 진입은 조건에 부합하면 진입은 설정했구요..
청산은 endtime에 일괄 청산으로 설정했는데요...
청산에 한 조건을 추가하고 싶어요... 30봉분으로 설정하였는데요...
청산조건
매수진입을 청산할때 양봉일때는 청산 하지 않고 다음 음봉일때 (또는 2회 연속 음봉일때 ) 청산
매도진입후 청산할때 음봉일때는 청산하지 않고 다음 양봉일때 (또는 2회 연속 양봉일때) 청산
할수 있는 수식좀 부탁합니다.
input : P1(-0.3),P2(0.8),P3(8),P4(-0.4),P5(0.4),p6(1000),starttime(223000),endtime(150000),P7(1.5),P8(0.8);
var : cnt(0),sum(0),sum1(0),mav(0),mav1(0),T(0),mav2(0),mav3(0);
var : sum3(0),Tcond(false);
Condition1 = MarketPosition == 0 and ExitDate(1) == sdate and
(IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) and
TimeToMinutes(stime) <= TimeToMinutes(ExitTime(1))+p6;
#설정
if sdate != sdate[1] then
SetStopEndofday(endtime);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
SetStopEndofday(0);#해제
}
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
if DayClose(P3) > 0 Then
{
sum = 0;
sum1 = 0;
for cnt = 0 to P3-1
{
sum = sum + DayClose(cnt);
sum1 = sum1 + DayClose(cnt+1);
}
mav = sum/P3;
mav1 = sum1/P3;
T = 0;
if mav > mav1 Then
T = 1;
if mav < mav1 Then
T = -1;
if T == 1 Then
mav2=p2 ;
if T == -1 Then
mav2=p5;
if T == 1 Then
mav3=p1 ;
if T == -1 Then
mav3=p4 ;
sum3 = 0;
for cnt = 1 to 20
{
sum3 = sum3 + (DayHigh(cnt)-DayLow(cnt));
}
value1 = sum3/20 ;
If MarketPosition == 0 and C >= (dayopen+value1*mav3) and C<C[1] and Condition1 == false Then
{
Buy("매수");
}
if MaxEntries == 1 and MarketPosition == 1 Then
{
buy("추가매수",atlimit,EntryPrice-P7);
}
If MarketPosition == 0 and C <= (dayopen-value1*mav2) and C>C[1] and Condition1 == false Then
{
sell("매도");
}
if MaxEntries == 1 and MarketPosition == -1 Then
{
Sell("추가매도",atlimit,EntryPrice+P8);
}
}
다음글
이전글