커뮤니티
익절 이후 익절가격 돌파할 경우만 거래 계속
익절1이 발생하면 다음 거래는 익절1 가격을 돌파해야 거래를 계속하는 수식으로 수정바랍니다.
익절2가 발생하면 마찬가지로 익절2가를 돌파해야 거래를 계속하는 수식으로 수정바랍니다.
아래 수식은 익절 발생과 상관없이 조건을 만족하면 거래를 수행합니다.
항상 고맙습니다.
******************************************************************************************************************************
input : 진입시간(084500),진입제한시간(150000);
input : 거래횟수(5),누적패수(5),연속패수(3),누적패수조정(4);
input : b1(1),진입눌림1(2),진입돌파1(3);
input : b2(2),진입눌림2(3),진입돌파2(4);
input : als(550),atr1(0),atr2(315);
input : bls(480),btr1(0),btr2(730);
input : b1lock(120000),익절1(330);
input : b2lock(140000),익절2(590);
var : T1(0),entry(0),LL(0),EH(0),E1(0),H1(0),i1(0),S1(0),L1(0),V1(0);
var : Tcond(false);
var : loss(0),consecLoss(0),패수(0);
//영업일변경
if bdate != bdate[1] Then
{
//손실횟수 초기화 0
loss = 0;
//연속손실횟수 초기화 0
consecLoss = 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;
}
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;
LL = L;
}
if stime >= 진입시간 then{
if L < LL Then
LL = L;
if MarketPosition == 0 Then
entry = TotalTrades-T1;
Else
entry = (TotalTrades-T1)+1;
if MarketPosition == 0 and entry == 0 Then{
if E1 == 0 and C >= LL+PriceScale*B1 Then{
E1 = 1;
H1 = H;
i1 = index;
V1 = LL; //시작점 종가
}
if E1 == 1 and index > i1 then{
if H > H1 Then
H1 = H;
#저가가 시작봉종가보다 클때만 눌림체크
if L >= V1 and L <= H1-PriceScale*진입눌림1 Then{
E1 = 2;
i1 = index;
S1 = H1;
}
}
//시작점 종가보다 낮은 가격이 발생하면 초기화
if E1 >= 1 and L < V1 Then{
E1 = 0;
LL = L;
}
if loss < 패수 and E1 == 2 and index > i1 and C >= S1+PriceScale*진입돌파1 and Tcond == true Then{
buy("b1");
}
}
if TotalTrades > TotalTrades[1] Then{
E1 = 0;
LL = L;
}
if L < LL Then
LL = L;
if MarketPosition == 0 and entry >= 1 and entry < 거래횟수 Then{
if E1 == 0 and C >= LL+PriceScale*B2 Then{
E1 = 1;
H1 = H;
i1 = index;
V1 = LL; //시작점 종가
}
if E1 == 1 and index > i1 then{
if H > H1 Then
H1 = H;
#저가가 시작봉종가보다 클때만 눌림체크
if L >= V1 and L <= H1-PriceScale*진입눌림2 Then{
E1 = 2;
i1 = index;
S1 = H1;
}
}
//시작점 종가보다 낮은 가격이 발생하면 초기화
if E1 >= 1 and L < V1 Then{
E1 = 0;
LL = L;
}
if loss < 패수 and loss < 누적패수 and E1 == 2 and index > i1 and C >= S1+PriceScale*진입돌파2 and Tcond == true Then{
buy("b2");
}
}
}
if MarketPosition== 1 Then
{
if IsEntryName("b1") == true Then
{
SetStopLoss(als,PointStop);
SetStopTrailing(atr2,atr1,PointStop,1);
}
Else if IsEntryName("b2") == true Then
{
SetStopLoss(bls,PointStop);
SetStopTrailing(btr2,btr1,PointStop,1);
}
Else
{
SetStopLoss(0);
SetStopTrailing(0,0);
}
}
if marketposition() == 1 and IsEntryName("b1") == true and stime<b1lock Then
ExitLong("익절1",Atlimit,EntryPrice+익절1);
if marketposition() == 1 and IsEntryName("b2") == true and stime<b2lock Then
ExitLong("익절2",Atlimit,EntryPrice+익절2);
SetStopEndofday(151500);
답변 1
예스스탁 예스스탁 답변
2025-11-06 10:37:45