예스스탁
예스스탁 답변
2020-01-22 12:43:10
안녕하세요
예스스탁입니다.
Input : shortPeriod(5), longPeriod(20);
value1 = ma(C, shortPeriod);
value2 = ma(C, longPeriod);
# 매수/매도청산
If CrossUP(value1, value2) Then
{
Buy("매수");
}
If CrossDown(value1, value2) Then
{
Sell("매도");
}
input : convert(30);
var : S1(0), D1(0), TM(0), TF1(0), rng1(0), rng2(0), OOO1(0), OOO2(0), CCC1(0), CCC2(0), cnt(0);
Array : OO[10](0), CC[10](0);
if bdate != bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1; # TM = TimeToMinutes(stime) - S1
Else
TM = TimeToMinutes(stime)+1440-S1; # 아니면 TM = TimeToMinutes(stime) + 1440 - S1
TF1 = TM % convert; # TF1 = TM 나누기 convert(30)의 '나머지'
if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF1 < TF1[1]) Then # TF[1]이 보다 유일하게 커질때가 30분 정각이다.(틱봉에선 반영이 잘 안되지만, 그래도 근사값을 구할수는 있다)
{
OO[0] = O;
CC[0] = C;
for cnt = 1 to 99
{
OO[cnt] = OO[cnt-1][1];
CC[cnt] = CC[cnt-1][1];
}
}
CC[0] = c;
}
// 청산<익절> ---------------------------------------------------------------------------------------------------------------
if MarketPosition == 1 Then
{
if OO[1] > CC[1] and OO[2] > CC[2] Then
ExitLong("2차 매수익절_1안",OnClose, def, "매수");
else if CurrentContracts == 1 Then
ExitLong("2차 매수본절익절_1안", atstop, EntryPrice, "매수", 1, 1);
}
if MarketPosition == -1 Then
{
if OO[1] < CC[1] and OO[2] < CC[2] Then
ExitShort("2차 매도익절_1안", OnClose,def, "매도");
else if CurrentContracts == 1 Then
ExitShort("2차 매도본절익절_1안", atstop, EntryPrice, "매도", 1, 1);
}
// 손절
SetStopLoss(10, PointStop);
즐거운 명절 되시기 바랍니다.
> 퀀트드래곤 님이 쓴 글입니다.
> 제목 : 틱봉을 분봉으로 만들어서 청산하기
> # 해외선물_ 틱봉 100틱 설정
# 매수 진입 후, 30분봉이 두번 연속 양봉이 나오면 이익청산
# 매도 진입 후, 30분봉이 두번 연속 음봉이 나오면 이익청산
위의 코딩 부탁드립니다.
아래처럼 여기저기 따와서 코딩했는데 안되네요..
도움되실까 하여 아래 제가 여기저기 따온 코드를 수록하였습니다.
# 진입 : 골든크로스 매수/ 데드크로스로 매도 -------------------------------------------------------------
Input : shortPeriod(5), longPeriod(20);
value1 = ma(C, shortPeriod);
value2 = ma(C, longPeriod);
# 매수/매도청산
If CrossUP(value1, value2) Then
{
Buy("매수");
}
# 매도/매수청산
If CrossDown(value1, value2) Then
{
Sell("매도");
}
input : convert(30);
var : S1(0), D1(0), TM(0), TF1(0), rng1(0), rng2(0), OOO1(0), OOO2(0), CCC1(0), CCC2(0), cnt(0);
Array : OO[10](0), CC[10](0);
if bdate != bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1; # TM = TimeToMinutes(stime) - S1
Else
TM = TimeToMinutes(stime)+1440-S1; # 아니면 TM = TimeToMinutes(stime) + 1440 - S1
TF1 = TM % convert; # TF1 = TM 나누기 convert(30)의 '나머지'
if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF1 < TF1[1]) Then # TF[1]이 보다 유일하게 커질때가 30분 정각이다.(틱봉에선 반영이 잘 안되지만, 그래도 근사값을 구할수는 있다)
{
OO[0] = O;
CC[0] = C;
for cnt = 1 to 99
{
OO[cnt] = OO[cnt-1][1];
CC[cnt] = CC[cnt-1][1];
}
}
}
if OO[1] != OO[2] Then
{
rng1 = CC[1]-OO[1];
rng2 = CC[2]-OO[2];
OOO1 = OO[1];
OOO2 = OO[2];
CCC1 = CC[1];
CCC2 = CC[2];
}
// 청산<익절> ---------------------------------------------------------------------------------------------------------------
if MarketPosition == 1 Then
{
if OOO1 > CCC1 and OOO2 > CCC2 Then # 첫번째 봉 음봉 and 두번째 봉 음봉 (2개 연속 봉 같은방향)
ExitLong("2차 매수익절_1안", AtLimit, 0, "매수");
else if CurrentContracts == 1 Then
ExitLong("2차 매수본절익절_1안", atstop, EntryPrice, "매수", 1, 1);
}
else if MarketPosition == -1 Then
{
if OOO1 < CCC1 and OOO2 < CCC2 Then # 첫번째 봉 양봉 and 두번째 봉 양봉 (2개 연속 봉 같은방향)
ExitShort("2차 매도익절_1안", AtLimit, 0, "매도");
else if CurrentContracts == 1 Then
ExitShort("2차 매도본절익절_1안", atstop, EntryPrice, "매도", 1, 1);
}
// 손절
SetStopLoss(10, PointStop);