예스스탁
예스스탁 답변
2021-11-09 13:14:50
안녕하세요
예스스탁입니다.
1
input : StartTime(205500),EndTime(222000);
input : Length(20), D1(2),n(10);
input : 익절(20),손절(15),익절연속횟수(3),손절연속횟수(2);
var : Tcond(false),profit(0),loss(0),T(0),S(0),Y(0);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
{
Tcond = False;
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
Tcond = true;
profit = 0;
loss = 0;
}
if TotalTrades > TotalTrades[1] Then
{
if IsExitName("bp.",1) or IsExitName("bp",1) or IsExitName("sp.",1) or IsExitName("sp",1) Then
profit = profit+1;
Else
profit = 0;
if IsExitName("bl.",1) or IsExitName("bl",1) or IsExitName("sl.",1) or IsExitName("sl",1) Then
loss = loss+1;
Else
loss = 0;
}
var1 = BollBandUp(Length,D1);
var2 = BollBandDown(Length,D1);
if Tcond == true Then
{
If CrossUP(H,var1) and c > o then
{
T = 1;
S = C;
Y = S;
}
If CrossDown(L,Var2) and C < O and profit < 익절연속횟수 and loss < 손절연속횟수 then
{
T = -1;
S = C;
Y = S;
}
if T == 1 and C < Y Then
Y = C;
if T == -1 and C > Y Then
Y = C;
If T == 1 and Y <= S-PriceScale*n and CrossUP(c,S) then
{
T = 2;
if profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Buy("b",OnClose,DEF,1);
ExitLong("bp.",AtLimit,C+PriceScale*익절,"",1,1);
ExitLong("bl.",AtStop,C-PriceScale*손절,"",1,1);
}
}
If T == -1 and Y >= S+PriceScale*n and crossdown(C,S) then
{
T = -2;
if profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Sell("s",OnClose,DEF,1);
ExitShort("sp.",AtLimit,C-PriceScale*익절,"",1,1);
ExitShort("sl.",AtStop,C+PriceScale*손절,"",1,1);
}
}
}
if MarketPosition == 1 Then
{
ExitLong("bp",AtLimit,EntryPrice+PriceScale*익절,"",1,1);
ExitLong("bl",AtStop,EntryPrice-PriceScale*손절,"",1,1);
}
if MarketPosition == -1 Then
{
ExitShort("sp",AtLimit,EntryPrice-PriceScale*익절,"",1,1);
ExitShort("sl",AtStop,EntryPrice+PriceScale*손절,"",1,1);
}
2
input : StartTime(223000),EndTime(234000);
input : Length(20), D1(2),n(10);
input : 익절(50),손절(30),익절연속횟수(3),손절연속횟수(2);
var : Tcond(false),profit(0),loss(0),T(0),S(0),Y(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;
profit = 0;
loss = 0;
}
if TotalTrades > TotalTrades[1] Then
{
if IsExitName("bp.",1) or IsExitName("bp",1) or IsExitName("sp.",1) or IsExitName("sp",1) Then
profit = profit+1;
Else
profit = 0;
if IsExitName("bl.",1) or IsExitName("bl",1) or IsExitName("sl.",1) or IsExitName("sl",1) Then
loss = loss+1;
Else
loss = 0;
}
var1 = BollBandUp(Length,D1);
var2 = BollBandDown(Length,D1);
if Tcond == true Then
{
If CrossUP(H,var1) and c > o then
{
T = 1;
S = C;
Y = S;
}
If CrossDown(L,Var2) and C < O then
{
T = -1;
S = C;
Y = S;
}
if T == 1 and C < Y Then
Y = C;
if T == -1 and C > Y Then
Y = C;
If T == 1 and Y <= S-PriceScale*n and CrossUP(c,S) then
{
T = 2;
if profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Buy("b",OnClose,DEF,1);
ExitLong("bp.",AtLimit,C+PriceScale*익절,"",1,1);
ExitLong("bl.",AtStop,C-PriceScale*손절,"",1,1);
}
}
If T == -1 and Y >= S+PriceScale*n and CrossUP(c,S) then
{
T = -2;
If profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Sell("s",OnClose,DEF,1);
ExitShort("sp.",AtLimit,C-PriceScale*익절,"",1,1);
ExitShort("sl.",AtStop,C+PriceScale*손절,"",1,1);
}
}
}
if MarketPosition == 1 Then
{
ExitLong("bp",AtLimit,EntryPrice+PriceScale*익절,"",1,1);
ExitLong("bl",AtStop,EntryPrice-PriceScale*손절,"",1,1);
}
if MarketPosition == -1 Then
{
ExitShort("sp",AtLimit,EntryPrice-PriceScale*익절,"",1,1);
ExitShort("sl",AtStop,EntryPrice+PriceScale*손절,"",1,1);
}
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);
}
}
즐거운 하루되세요
> 호정0688 님이 쓴 글입니다.
> 제목 : 문의드립니다
> 항상 감사드립니다.
아래 두개의 수식에도 신호 나온 캔들의 종가에 진입하는데,
n틱 이상 조정 받고 다시 종가를 돌파할때 매수 매도 들어가는 수식을
추가해서 수정 부탁드립니다.
1.
input : StartTime(205500),EndTime(222000);
input : Length(20), D1(2);
input : 익절(20),손절(15),익절연속횟수(3),손절연속횟수(2);
var : Tcond(false),profit(0),loss(0);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
{
Tcond = False;
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
Tcond = true;
profit = 0;
loss = 0;
}
if TotalTrades > TotalTrades[1] Then
{
if IsExitName("bp.",1) or IsExitName("bp",1) or IsExitName("sp.",1) or IsExitName("sp",1) Then
profit = profit+1;
Else
profit = 0;
if IsExitName("bl.",1) or IsExitName("bl",1) or IsExitName("sl.",1) or IsExitName("sl",1) Then
loss = loss+1;
Else
loss = 0;
}
var1 = BollBandUp(Length,D1);
var2 = BollBandDown(Length,D1);
if Tcond == true Then
{
If CrossUP(H,var1) and c > o and profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Buy("b",OnClose,DEF,1);
ExitLong("bp.",AtLimit,C+PriceScale*익절,"",1,1);
ExitLong("bl.",AtStop,C-PriceScale*손절,"",1,1);
}
If CrossDown(L,Var2) and C < O and profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Sell("s",OnClose,DEF,1);
ExitShort("sp.",AtLimit,C-PriceScale*익절,"",1,1);
ExitShort("sl.",AtStop,C+PriceScale*손절,"",1,1);
}}
if MarketPosition == 1 Then
{
ExitLong("bp",AtLimit,EntryPrice+PriceScale*익절,"",1,1);
ExitLong("bl",AtStop,EntryPrice-PriceScale*손절,"",1,1);
}
if MarketPosition == -1 Then
{
ExitShort("sp",AtLimit,EntryPrice-PriceScale*익절,"",1,1);
ExitShort("sl",AtStop,EntryPrice+PriceScale*손절,"",1,1);
}
2.
input : StartTime(223000),EndTime(234000);
input : Length(20), D1(2);
input : 익절(50),손절(30),익절연속횟수(3),손절연속횟수(2);
var : Tcond(false),profit(0),loss(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;
profit = 0;
loss = 0;
}
if TotalTrades > TotalTrades[1] Then
{
if IsExitName("bp.",1) or IsExitName("bp",1) or IsExitName("sp.",1) or IsExitName("sp",1) Then
profit = profit+1;
Else
profit = 0;
if IsExitName("bl.",1) or IsExitName("bl",1) or IsExitName("sl.",1) or IsExitName("sl",1) Then
loss = loss+1;
Else
loss = 0;
}
var1 = BollBandUp(Length,D1);
var2 = BollBandDown(Length,D1);
if Tcond == true Then
{
If CrossUP(H,var1) and c > o and profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Buy("b",OnClose,DEF,1);
ExitLong("bp.",AtLimit,C+PriceScale*익절,"",1,1);
ExitLong("bl.",AtStop,C-PriceScale*손절,"",1,1);
}
If CrossDown(L,Var2) and C < O and profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Sell("s",OnClose,DEF,1);
ExitShort("sp.",AtLimit,C-PriceScale*익절,"",1,1);
ExitShort("sl.",AtStop,C+PriceScale*손절,"",1,1);
}
}
if MarketPosition == 1 Then
{
ExitLong("bp",AtLimit,EntryPrice+PriceScale*익절,"",1,1);
ExitLong("bl",AtStop,EntryPrice-PriceScale*손절,"",1,1);
}
if MarketPosition == -1 Then
{
ExitShort("sp",AtLimit,EntryPrice-PriceScale*익절,"",1,1);
ExitShort("sl",AtStop,EntryPrice+PriceScale*손절,"",1,1);
}
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);
}
}