커뮤니티
제가 활용하고 있는 수식에 손절매와 목표수익을 수식에 변수로 입력하게 해주세요~~
2018-10-26 08:07:50
127
글번호 123075
설정창에 손절매와 목표수익을 기입해서 운영했는데 생각보다 결과가 않좋게 나와
최적화를 할려고 합니다. 그래서 손절매와 목표수익을 변수 수식에 반영 부탁드림니다.
최적화 돌려서 검증해보려고 합니다. 아래 수식에 반영 부탁드리겠습니다.
========================================================================================
input : P1(0.1),P2(0.8),P3(14),P4(-0.4),P5(0.5),p6(1000),starttime(223000),endtime(150000),P7(1.9),P8(0.5);
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);
}
}
답변 1
예스스탁 예스스탁 답변
2018-10-26 16:27:43
안녕하세요
예스스탁입니다.
input : P1(0.1),P2(0.8),P3(14),P4(-0.4),P5(0.5),p6(1000),starttime(223000),endtime(150000),P7(1.9),P8(0.5);
input : 손절틱수(20),익절틱수(20);
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);
}
}
SetStopLoss(PriceScale*손절틱수,PointStop);
SetStopProfittarget(PriceScale*익절틱수,PointStop);
즐거운 하루되세요
> 이형지 님이 쓴 글입니다.
> 제목 : 제가 활용하고 있는 수식에 손절매와 목표수익을 수식에 변수로 입력하게 해주세요~~
> 설정창에 손절매와 목표수익을 기입해서 운영했는데 생각보다 결과가 않좋게 나와
최적화를 할려고 합니다. 그래서 손절매와 목표수익을 변수 수식에 반영 부탁드림니다.
최적화 돌려서 검증해보려고 합니다. 아래 수식에 반영 부탁드리겠습니다.
========================================================================================
input : P1(0.1),P2(0.8),P3(14),P4(-0.4),P5(0.5),p6(1000),starttime(223000),endtime(150000),P7(1.9),P8(0.5);
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);
}
}
다음글
이전글