예스스탁
예스스탁 답변
2021-11-01 09:27:04
안녕하세요
예스스탁입니다.
해당 진입내용을 즉시진입으로 변경하면
!(H <= H[1] and L >= L[1]) 조건은 판별이 불가능합니다.
고가와 저가는 봉완성시에만 최종확인이 되어서 봉미완성시에 판별을 불가능합니다.
해당 내용은 제외하고 변경해 드립니다.
3번 내용은 당일청산을 안하는것과 같습니다.
현재는 지정한 endtime에 포지션이 있으면 청산을 하게 되어 있습니다.
종료시간이후에도 손절이나 익절이 발생하게 하기 위해서는 당일청산내용을 삭제하시면 됩니다.
input : ntime1(5),n1(10),n2(30);
input : StartTime(222500),EndTime(010000);
input : 익절틱수(50),손절틱수(40);
var : S1(0),D1(0),TM(0),TF1(0),TF2(0),cnt(0);
var : Tcond(false),Xcond(False),Profit(0),loss(0);
Array : H1[50](0),L1[50](0),H2[50](0),L2[50](0);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
Tcond = true;
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
Profit = 0;
Loss = 0;
Xcond = False;
}
if TotalTrades > TotalTrades[1] Then
{
if IsExitName("StopLoss",1) == true Then
{
loss = loss+1;
if loss == 2 Then
Xcond = true;
}
Else
loss = 0;
if IsExitName("StopProfittarget",1) == true Then
{
Profit = Profit+1;
if Profit == 2 Then
Xcond = true;
}
Else
Profit = 0;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF1 = TM%ntime1;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime1 > 1 and TF1 < TF1[1]) or
(Bdate == Bdate[1] and ntime1 > 1 and TM >= TM[1]+ntime1) or
(Bdate == Bdate[1] and ntime1 == 1 and TM > TM[1]) Then
{
H1[0] = H;
L1[0] = L;
For cnt = 1 to 49
{
H1[cnt] = H1[cnt-1][1];
L1[cnt] = L1[cnt-1][1];
}
}
if H1[0] > 0 and H > H1[0] Then
H1[0] = H;
if L1[0] > 0 and L < L1[0] Then
L1[0] = L;
if Tcond == true Then
{
if MarketPosition <= 0 and Xcond == False and H1[n1] > 0 and H1[n1] > 0 and NextBarOpen <= max(H1[n1],H2[n2]) Then
Buy("b",AtStop,max(H1[n1],H2[n2])+PriceScale*1);
if MarketPosition >= 0 and Xcond == False and L1[n1] > 0 and L1[n2] > 0 and NextBarOpen >= min(L1[n1],L2[n2]) Then
Sell("s",AtStop,min(L1[n1],L2[n2])-PriceScale*1);
if MarketPosition == 1 Then
ExitLong("bx",AtStop,L-PriceScale*1);
if MarketPosition == -1 Then
ExitShort("sx",AtStop,H+PriceScale*1);
}
}
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
즐거운 하루되세요
> jesten77 님이 쓴 글입니다.
> 제목 : 문의 드립니다.
> 항상 감사드립니다.
아래 수식은 종가에 진입하고 거래시간 종료에 청산하는 수식인데요.
아래 내용으로 수정 부탁드립니다.
1. 조건 완성시 즉시 진입
2. 익절 두번 연속, 손절이 두번 연속될 경우, 거래 종료
3. 거래시간내에 진입한 거래가 종료전에 익절, 손절이 안될 경우, 거래시간 종료이후에 같은 조건으로 익절, 손절 청산.
input : ntime1(5),n1(10),n2(30);
input : StartTime(222500),EndTime(010000);
input : 익절틱수(50),손절틱수(40);
var : S1(0),D1(0),TM(0),TF1(0),TF2(0),cnt(0);
var : Tcond(false);
Array : H1[50](0),L1[50](0),H2[50](0),L2[50](0);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
Tcond = true;
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF1 = TM%ntime1;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime1 > 1 and TF1 < TF1[1]) or
(Bdate == Bdate[1] and ntime1 > 1 and TM >= TM[1]+ntime1) or
(Bdate == Bdate[1] and ntime1 == 1 and TM > TM[1]) Then
{
H1[0] = H;
L1[0] = L;
For cnt = 1 to 49
{
H1[cnt] = H1[cnt-1][1];
L1[cnt] = L1[cnt-1][1];
}
}
if H1[0] > 0 and H > H1[0] Then
H1[0] = H;
if L1[0] > 0 and L < L1[0] Then
L1[0] = L;
if Tcond == true Then
{
if H1[n1] > 0 and H1[n1] > 0 and C > H1[n1] and C > H1[n2] and C > O and !(H <= H[1] and L >= L[1]) Then
Buy();
if L1[n1] > 0 and L1[n2] > 0 and C < L1[n1] and C < L1[n2] and C < O and !(H <= H[1] and L >= L[1]) Then
Sell();
if MarketPosition == 1 Then
ExitLong("bx",AtStop,L-PriceScale*1);
if MarketPosition == -1 Then
ExitShort("sx",AtStop,H+PriceScale*1);
}
}
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
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
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}