안녕하세요.
다음식의 자세한 주석 부탁드립니다.
input : ntime(60),n(10);
input : StartTime(70000),EndTime(30000);
var : S1(0),D1(0),TM(0),TF(0);
var : cnt(0),SumSqrt(0),Stdv(0);
var : sum(0),BBmd(0),Bbup(0),BBdn(0);
Array : CC[100](0);
var : Tcond(false);
if (NextBarSdate != sdate and NextBarStime >= EndTime) or
(NextBarSdate == sdate and NextBarStime >= EndTime and stime < EndTime) Then
Tcond = False;
if (NextBarSdate != sdate and NextBarStime >= StartTime) or
(NextBarSdate == sdate and NextBarStime >= StartTime and stime < StartTime) Then
{
Tcond = true;
S1 = TimeToMinutes(NextBarStime);
D1 = NextBarSdate;
}
if D1 > 0 then
{
if NextBarSdate == D1 Then
TM = TimeToMinutes(NextBarStime)-S1;
Else
TM = TimeToMinutes(NextBarStime)+1440-S1;
TF = TM%ntime;
if NextBarSdate != sdate or
(NextBarSdate == sdate and ntime > 1 and TF < TF[1]) or
(NextBarSdate == sdate and ntime > 1 and TM >= TM[1]+ntime) or
(NextBarSdate == sdate and ntime == 1 and TM > TM[1]) Then
{
var1 = NextBarOpen;
}
if Tcond == true and MarketPosition <= 0 Then
Buy("b",AtStop,var1+PriceScale*n);
if Tcond == true and MarketPosition >= 0 Then
Sell("s",AtStop,var1-PriceScale*n);
}
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);
}
}
Sell("s",AtStop,var1-PriceScale*n);
}
답변 1
예스스탁
예스스탁 답변
2022-08-01 15:59:09
안녕하세요
예스스탁입니다.
input : ntime(60),n(10);
input : StartTime(70000),EndTime(30000);
var : S1(0),D1(0),TM(0),TF(0);
var : cnt(0),SumSqrt(0),Stdv(0);
var : sum(0),BBmd(0),Bbup(0),BBdn(0);
Array : CC[100](0);
var : Tcond(false);
#지정한 endtime(3시)이후 첫봉이 발생하면
if (NextBarSdate != sdate and NextBarStime >= EndTime) or
(NextBarSdate == sdate and NextBarStime >= EndTime and stime < EndTime) Then
{
#Tcond는 False
Tcond = False;
}
#지정한 Starttime(7시)이후 첫봉이 발생하면
if (NextBarSdate != sdate and NextBarStime >= StartTime) or
(NextBarSdate == sdate and NextBarStime >= StartTime and stime < StartTime) Then
{
#Tcond는 true
Tcond = true;
#첫봉의 시가시간을 0시이후 경과한 분으로 환산해 저장(7시면 420분)
S1 = TimeToMinutes(NextBarStime);
#날짜 저장
D1 = NextBarSdate;
}
#차트상 첫 시작시간봉이 나온이후에
if D1 > 0 then
{
#시작봉시간과 현재 시간 사이에 경과한 분을 계산
#현재날짜가 첫봉시가의 날짜와 같으면
if NextBarSdate == D1 Then
#현재봉 0시 이후 경과한 분에서 첫봉시가의 0시 이후 경관한 분을 빼서 경과한 분을 계산하고
TM = TimeToMinutes(NextBarStime)-S1;
Else #현재날짜가 첫봉시가의 날짜가 다르면(다음날 새벽)
TM = TimeToMinutes(NextBarStime)+1440-S1; #1440분을 더해서 경과한 시간을 계산
#첫봉이후 경과한 분을 60으로 나누어서 나머지를 계산
#경과한분을 60으로 나누면 나머지가 0~59로 리턴됨
TF = TM%ntime;
#첫봉이거나 60분 단위 첫봉이 나오면
if NextBarSdate != sdate or
(NextBarSdate == sdate and ntime > 1 and TF < TF[1]) or
(NextBarSdate == sdate and ntime > 1 and TM >= TM[1]+ntime) or
(NextBarSdate == sdate and ntime == 1 and TM > TM[1]) Then
{
#시가저장
var1 = NextBarOpen;
}
#지정한 시간사이에 60분 단위 시가+n틱 상승하면 매수
if Tcond == true and MarketPosition <= 0 Then
Buy("b",AtStop,var1+PriceScale*n);
#지정한 시간사이에 60분 단위 시가-n틱 하락하면 매도
if Tcond == true and MarketPosition >= 0 Then
Sell("s",AtStop,var1-PriceScale*n);
}
#당일청산은 지정한 시간이후에 진입을 막기때문에
#당일에 청산하는 경우와 다음날 새벽에 청산하는 경우를 구분해서
#처리해야 함
#끝시간이 시작시간보다 크면 당일청산 셋팅
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else#아니면 (끝시간이 시작시간보다 작은경우는 새벽에 청산하는 경우임)
{
#0시기준 날짜변경되면 당일청산 셋팅ㄹ
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);
}
}
즐거운 하루되세요
> 예스요 님이 쓴 글입니다.
> 제목 : 문의 드립니다.~~~~
> 안녕하세요.
다음식의 자세한 주석 부탁드립니다.
input : ntime(60),n(10);
input : StartTime(70000),EndTime(30000);
var : S1(0),D1(0),TM(0),TF(0);
var : cnt(0),SumSqrt(0),Stdv(0);
var : sum(0),BBmd(0),Bbup(0),BBdn(0);
Array : CC[100](0);
var : Tcond(false);
if (NextBarSdate != sdate and NextBarStime >= EndTime) or
(NextBarSdate == sdate and NextBarStime >= EndTime and stime < EndTime) Then
Tcond = False;
if (NextBarSdate != sdate and NextBarStime >= StartTime) or
(NextBarSdate == sdate and NextBarStime >= StartTime and stime < StartTime) Then
{
Tcond = true;
S1 = TimeToMinutes(NextBarStime);
D1 = NextBarSdate;
}
if D1 > 0 then
{
if NextBarSdate == D1 Then
TM = TimeToMinutes(NextBarStime)-S1;
Else
TM = TimeToMinutes(NextBarStime)+1440-S1;
TF = TM%ntime;
if NextBarSdate != sdate or
(NextBarSdate == sdate and ntime > 1 and TF < TF[1]) or
(NextBarSdate == sdate and ntime > 1 and TM >= TM[1]+ntime) or
(NextBarSdate == sdate and ntime == 1 and TM > TM[1]) Then
{
var1 = NextBarOpen;
}
if Tcond == true and MarketPosition <= 0 Then
Buy("b",AtStop,var1+PriceScale*n);
if Tcond == true and MarketPosition >= 0 Then
Sell("s",AtStop,var1-PriceScale*n);
}
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);
}
}
Sell("s",AtStop,var1-PriceScale*n);
}