커뮤니티
진입/이익청산은 봉완성시 ... 손절청산은 조건만족시 즉시 로 작동할수 있게 요청합니다.
2018-11-04 11:25:22
193
글번호 123335
제가 현재 사용중인 수식인데요...
진입 및 청산 시점은 설정에서 봉완성후로 설정해서 사용하고 싶습니다.
하지만 그러다보니 청산시점 특히 손절할 포인트가 봉청산시점이라서 상당히 큰 손실을 본적이 있어서요..
그렇다고 진입은 봉완성시로 진입하고 싶거든요...
아래 수식에서
"진입은 봉완성시 작동
청산(익절)도 봉완성시 작동
청산(손절)시 조건 만족시 즉시
로 할수 있게 도와주세요~~~
------------------------------------------------------------------------------------
input : P1(-0.4),P2(0.8),P3(20),P4(0.2),P5(0.4),p6(870),starttime(230000),endtime(150000),P7(1.9),P8(0.5);
input : 손절틱수(54),익절틱수(80);
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);#해제
Condition1 = false;
}
if TotalTrades > TotalTrades[1] and
(IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) Then
Condition1 = true;
if Condition1 == true and BarsSinceExit(1) >= P6 Then
Condition1 = false;
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);
답변 1
예스스탁 예스스탁 답변
2018-11-05 15:28:45
안녕하세요
예스스탁입니다.
설정창의 강제청산탭의 청산시점은 강제청산에만 해당하는 내용입니다.
설정창에서 강제청산 지정하시거나 수식안에서 강제청산함수로 지정하는 내용만
해당 옵션이 적용됩니다.
수식에서 사용하는 일반신호함수(Buy,Sell,Exitlong,Exitshort)와는 관계가 없습니다.
모든 진입과 익절은 봉완성시로 수정했습니다.
손절만 강제청산 함수로 동작하므로 청산시점은 조건만족즉시로 셋팅하고
적용하시면 됩니다.
input : P1(-0.4),P2(0.8),P3(20),P4(0.2),P5(0.4),p6(870),starttime(230000),endtime(150000),P7(1.9),P8(0.5);
input : 손절틱수(54),익절틱수(80);
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);#해제
Condition1 = false;
}
if TotalTrades > TotalTrades[1] and
(IsExitName("StopLoss",1) or IsExitName("StopProfitTarget",1)) Then
Condition1 = true;
if Condition1 == true and BarsSinceExit(1) >= P6 Then
Condition1 = false;
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 and C <= EntryPrice-P7 Then
{
buy("추가매수");
}
If MarketPosition == 0 and C <= (dayopen-value1*mav2) and C>C[1] and Condition1 == false Then
{
sell("매도");
}
if MaxEntries == 1 and MarketPosition == -1 and C >= EntryPrice+P8 Then
{
Sell("추가매도");
}
}
if MarketPosition == 1 and C >= EntryPrice+PriceScale*익절틱수 Then
ExitLong("매수익절");
if MarketPosition == -1 and C <= EntryPrice-PriceScale*익절틱수 Then
ExitShort("매도익절");
SetStopLoss(PriceScale*손절틱수,PointStop);
즐거운 하루되세요
> 이형지 님이 쓴 글입니다.
> 제목 : 진입/이익청산은 봉완성시 ... 손절청산은 조건만족시 즉시 로 작동할수 있게 요청합?