커뮤니티
문의
sell 수식에서 익절 발생 후 그 이후 진입은 익절가보다 낮은 가격에서 진입하도록
수식을 수정했는데...익절가 발생 후 부터는 아예 진입을 하지 않는 수식이 되었습니다.
살펴주십시요.
첨부파일 1은 기존 수식 결과
첨부파일 2는 수정 수식 결과
***************************************************************************************************************************
input : 최대(999999),최소(550);
input : 진입시간(084700),진입제한시간(142400);
input : 거래횟수(20),누적패수(5),연속패수(2),누적패수조정(2),bigdown(15.00),조정거래횟수(7),조정진입제한시간(113000);
input : b1(50),진입눌림1(5),진입돌파1(0),X1(999999),청산눌림1(0),청산돌파1(0);
input : 경과봉(0),b2(150),진입눌림2(5),진입돌파2(0),X2(999999),청산눌림2(0),청산돌파2(0);
input : als(40),atr1(0),atr2(135);
input : bls(130),btr1(0),btr2(182);
input : s1lock(120000),익절가1(8);
input : s2lock(115000),익절가2(4.9);
input : 만기청산시간1(144500),만기외청산시간1(150000);
input : 만기청산시간2(150000),만기외청산시간2(142400);
var : T1(0),entry(0),HH(0),LL(0),EH(0),EL(0),E1(0),H1(0),i1(0),S1(0),L1(0),V1(0);
Var : 당일거래횟수(0),진입끝시간(0),bigdownCond(False);
var : Tcond(false);
var : loss(0),consecLoss(0),패수(0),익절가(0);
//영업일변경
if bdate != bdate[1] Then
{
//손실횟수 초기화 0
loss = 0;
//연속손실횟수 초기화 0
consecLoss = 0;
//패수는 누적패수
패수 = 누적패수;
//익절1이나 익절2가 발생하면 청산가격 저장할 변수
익절가 = 0;
}
//청산발생
if TotalTrades > TotalTrades[1] Then
{
//손실이면
if PositionProfit(1) < 0 Then
{
//loss 1씩 증가
loss = loss+1;
//consecLoss 1씩 증가
consecLoss = consecLoss+1;
//consecLoss이 3이면 패수를 누적패수에서 누적패수조정으로 변경
if consecLoss == 연속패수 Then
{
패수 = 누적패수조정;
}
}
Else //손실이 아니면 consecLoss으로 초기화
consecLoss = 0;
//청산으로 익절1이나 익절2이면 익절가에 청산가격 저장
if IsExitName("익절1",1) == true or IsExitName("익절2",1) == true Then
익절가 = ExitPrice(1);
Else // 아니면
익절가 = 0; //익절가는 0
}
//영업일 변경
if bdate != bdate[1] Then
{
//손실횟수 초기화 0
loss = 0;
//연속손실횟수 초기화 0
consecLoss = 0;
//패수는 누적패수
패수 = 누적패수;
//당일거래횟수는 거래횟수
당일거래횟수 = 거래횟수;
//진입끝시간은 진입제한시간
진입끝시간 = 진입제한시간;
//bigdownCond는 False
bigdownCond = False;
}
//bigdownCond가 False인 상태에서
//진입시간이후 조정진입제한시간 전에 시초가대비 BigDown이하 하락한 종가가 발생하면
if bigdownCond == False and
stime >= 진입시간 and sTime < 조정진입제한시간 and
L <= DayOpen-BigDown Then //전일종가대비이면 DayOpen-> DayClose(1)
{
//BigDown는 true
bigdownCond = true;
//당일거래횟수는 조정거래횟수로 변경
당일거래횟수 = 조정거래횟수;
//진입끝시간은 조정진입제한시간로 변경
진입끝시간 = 조정진입제한시간;
//진입제한시간이후에 발생했다면 Tcond가 False이므로
//Tcond는 true로 변경
if sTime >= 진입제한시간 and Tcond == False Then
Tcond = true;
}
if TotalTrades > TotalTrades[1] and PositionProfit(1) < 0 Then
loss = loss+1;
if (sdate != sdate[1] and stime >= 진입시간) or
(sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then
Tcond = true;
if (sdate != sdate[1] and stime >= 진입끝시간) or
(sdate == sdate[1] and stime >= 진입끝시간 and stime[1] < 진입끝시간) Then
Tcond = false;
if (sdate != sdate[1] and stime >= 진입시간) or
(sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then{
T1 = TotalTrades;
E1 = 0;
HH = H;
}
if stime >= 진입시간 then
{
if H > HH Then
HH = H;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 Then
{
if E1 == 0 and C <= HH-PriceScale*B1 Then
{
E1 = 1;
L1 = L;
i1 = index;
V1 = HH; //시작점 종가
}
if E1 == 1 and index > i1 then{
if L < L1 Then
L1 = L;
#고가가 시작봉종가보다 작을 때만 눌림체크
if H <= V1 and H >= L1+PriceScale*진입눌림1 Then{
E1 = 2;
i1 = index;
S1 = L1;
}
}
//시작점 종가보다 높은 가격이 발생하면 초기화
if E1 >= 1 and H > V1 Then{
E1 = 0;
HH = H;
}
if loss < 패수 and E1 == 2 and index > i1 and C <= S1-PriceScale*진입돌파1 and Tcond == true and 최대 > C and C >= 최소 Then{
sell("s1");
}
}
if TotalTrades > TotalTrades[1] Then{
E1 = 0;
HH = H;
}
if H > HH Then
HH = H;
if MarketPosition == 0 and entry >= 1 and entry < 당일거래횟수 Then{
if E1 == 0 and C <= HH-PriceScale*B2 Then{
E1 = 1;
L1 = L;
i1 = index;
}
if E1 == 1 and index > i1 then{
if L < L1 Then
L1 = L;
if H >= L1+PriceScale*진입눌림2 Then{
E1 = 2;
i1 = index;
S1 = L1;
}
}
if loss < 패수 and E1 == 2 and index > i1 and C <= S1-PriceScale*진입돌파2 and Tcond == true and 최대 > C and C >= 최소 and
(익절가 == 0 or (익절가 > 0 and C < 익절가)) Then //익절가가 0이거나 익절가가 0보다 크면 종가가 익절가보다 작다 Then{
sell("s2");
E1 = 0;
}
}
if MarketPosition == -1 and IsEntryName("s1") == true Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
EL = L;
E1 = 0;
}
if L < EL Then{
EL = L;
E1 = 0;
}
if E1 == 0 and C >= EL+PriceScale*X1 Then{
E1 = 1;
H1 = H;
i1 = index;
}
if E1 == 1 and index > i1 Then{
if H > H1 Then
H1 = H;
if L <= H1-PriceScale*청산눌림1 Then{
E1 = 2;
I1 = index;
S1 = H1;
}
}
if E1 == 2 and index > i1 and C >= S1+PriceScale*청산돌파1 Then{
ExitShort("sx1");
E1 = 0;
}
}
}
if MarketPosition == -1 and IsEntryName("s2") == true Then{
if entry >= 1 then{
if CurrentContracts > CurrentContracts[1] Then{
EL = L;
E1 = 0;
}
if L < EL Then{
EL = L;
E1 = 0;
}
if E1 == 0 and C >= EL+PriceScale*X2 Then{
E1 = 1;
H1 = H;
i1 = index;
}
if E1 == 1 and index > i1 Then{
if H > H1 Then
H1 = H;
if L <= H1-PriceScale*청산눌림2 Then{
E1 = 2;
I1 = index;
S1 = H1;
}
}
if E1 == 2 and index > i1 and C >= S1+PriceScale*청산돌파2 Then{
ExitShort("sx2");
E1 = 0;
}
}
}
if marketposition() == -1 and IsEntryName("s1") == true and stime<s1lock Then
ExitShort("익절가1",Atlimit,EntryPrice-익절가1);
if marketposition() == -1 and IsEntryName("s2") == true and stime<s2lock Then
ExitShort("익절가2",Atlimit,EntryPrice-익절가2);
if MarketPosition== -1 Then
{
if IsEntryName("s1") == true Then
{
SetStopLoss(PriceScale*als,PointStop);
SetStopTrailing(PriceScale*atr2,PriceScale*atr1,PointStop,1);
}
Else if IsEntryName("s2") == true Then
{
SetStopLoss(PriceScale*bls,PointStop);
SetStopTrailing(PriceScale*btr2,PriceScale*btr1,PointStop,1);
}
Else
{
SetStopLoss(0);
SetStopTrailing(0,0);
}
}
var : Month(0),nday(0),week(0);
month = int(date/100)-int(date/10000)*100;
nday = date - int(date/100)*100;
Week = DayOfWeek(date);
if (nday >= 8 and nday <= 14 and
week == 4) or (sdate == 20141008) then
{
if sdate < 20160801 Then
SetStopEndofday(만기청산시간1);
Else
SetStopEndofday(만기청산시간2);
}
Else
{
if sdate < 20160801 Then
SetStopEndofday(만기외청산시간1);
Else
SetStopEndofday(만기외청산시간2);
}
답변 1
예스스탁 예스스탁 답변
2025-11-13 10:49:03