커뮤니티
복합시스템식 부탁합니다
2015-04-05 17:25:51
244
글번호 84750
지그재그패턴과
중단기추세의
신호가 동시에
발생하는 캔들을
시스템식으로
만들어주세요.
다음은 시스템식입니다
지그재그패턴=
Input:length(5);
Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0);
Array:valArr[10](0),barArr[10](0),turnPntArr[10]("");
// 봉이 새로 생겼으므로 봉개수 관리하는 변수들의 봉개수 값 1씩 증가
For j = 0 To 9
{
barArr[j] = barArr[j] + 1;
}
// 고점조건 = 현재 봉의 고가가 기간최고가이면서 최고가 갱신되었을 때;
// 저점조건 = 현재 봉의 저가가 기간최저가이면서 최저가 갱신되었을 때;
// 고점,저점조건 만족시 현재 봉의 고[저]가를 변수에 저장
Condition1 = Highest(H,length) == H and lastHiVal <> H;
Condition2 = Lowest(L,length) == L and lastLoVal <> L;
If Condition1 Then lastHiVal = H;
If Condition2 Then lastLoVal = L;
// 전환점구분 null값으로 초기화;
turnPntBit = "";
// if 고점조건, 저점조건 동시 만족시 then
// if 이전 고점,저점 범위를 모두 벗어났을 때
// 전환점구분 = 고저점;
// else if 이전 고점을 갱신했다면 전환점구분 = 고점;
// else if 이전 저점을 갱신했다면 전환점구분 = 저점;
// else if 고점조건 만족하면 전환점구분 = 고점;
// else if 저점조건 만족하면 전환점구분 = 저점;
If Condition1 and Condition2 Then
{
If Max(valArr[1],valArr[2]) < H and Min(valArr[1],valArr[2]) > L Then
turnPntBit = "HiLo";
Else If Max(valArr[1],valArr[2]) < H Then turnPntBit = "Hi";
Else If Min(valArr[1],valArr[2]) > L Then turnPntBit = "Lo";
}
Else If Condition1 Then turnPntBit = "Hi";
Else If Condition2 Then turnPntBit = "Lo";
// if 전환점구분에 값이 있을 때만 then 아래 실행, 없으면 통과
If turnPntBit <> "" Then
{
// if 전환점구분이 고저점이면 then
// 이전 파동은 연장시키고 아래에서 새로이 파동선을 추가토록 한다.
If turnPntBit == "HiLo" Then
{
valArr[1] = IFF(turnPntArr[1] == "Hi",H,L);
barArr[1] = 0;
TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]);
If turnPntArr[1] == "Hi" Then
turnPntBit = "Lo";
Else
turnPntBit = "Hi";
}
// if 신규 전환점구분이 현재(전환점배열 1번째)와 다르면 then
// 배열값들을 이전값으로 Move;
If turnPntBit <> turnPntArr[1] Then
{
for j = 8 downto 1
{
valArr[j+1] = valArr[j];
barArr[j+1] = barArr[j];
turnPntArr[j+1] = turnPntArr[j];
}
}
// if 전환점구분이 바뀌었거나 또는
// (전환점구분은 안바뀌었는데
// (이전 고점보다 높은 고점이 발생했거나 또는
// 이전 저점보다 낮은 저점이 발생했으면)) then
If turnPntBit <> turnPntArr[1] or
(turnPntBit == turnPntArr[1] and
((turnPntBit == "Hi" and valArr[1] < H) or
(turnPntBit == "Lo" and valArr[1] > L))) Then
{
// 값 배열에는 고점 또는 저점을 대입;
// 봉개수 배열에는 0값 대입;
// 전환점 배열에 전환점구분값을 대입;
valArr[1] = IFF(turnPntBit == "Hi",H,L);
barArr[1] = 0;
turnPntArr[1] = turnPntBit;
// if 이전봉대비 전환점구분이 바뀌었다면 추세선 새로 그리고;
// else 전환점구분이 안바뀌었으면 값만 바뀐거므로 추세선 연장;
If turnPntArr[1][1] <> turnPntArr[1][0] Then{
TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]);
if turnPntArr[1] == "Hi" Then
buy();
if turnPntArr[1] == "Lo" Then
sell();
}
Else
TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]);
}
}
중단기추세=
Input:n(5),미완성사용(1);
Var:j(0),q(0),k(0),상단(200),하단(100),고점표시(0),저점표시(0),Exit(100),
고점갱신(False),저점갱신(False),중기고점갱신(False),중기저점갱신(False),
중기추세갱신(0),장기추세갱신(0),
단기상단기울기(0),단기상단Bar(0),단기상단절편(0),단기하단기울기(0),
단기하단Bar(0),단기하단절편(0),
중기상단기울기(0),중기상단Bar(0),중기상단절편(0),중기하단기울기(0),
중기하단Bar(0),중기하단절편(0),
장기상단기울기(0),장기상단Bar(0),장기상단절편(0),장기하단기울기(0),
장기하단Bar(0),장기하단절편(0),
단기상단채널(0),단기하단채널(0),중기상단채널(0),중기하단채널(0),
장기상단채널(0),장기하단채널(0);
Array:고[50](0),저[50](0),고Bar[50](0),저Bar[50](0),
중기고[20](0),중기저[20](0),중기고Bar[20](0),중기저Bar[20](0),
장기고[20](0),장기저[20](0),장기고Bar[20](0),장기저Bar[20](0);
#==========================================#
# 초기처리 (Initialize Routine)
#==========================================#
for j = 1 to 19 {
고Bar[j] = 고Bar[j] + 1;
저Bar[j] = 저Bar[j] + 1;
중기고Bar[j] = 중기고Bar[j] + 1;
중기저Bar[j] = 중기저Bar[j] + 1;
장기고Bar[j] = 장기고Bar[j] + 1;
장기저Bar[j] = 장기저Bar[j] + 1;
}
for j = 20 to 49 {
고Bar[j] = 고Bar[j] + 1;
저Bar[j] = 저Bar[j] + 1;
}
단기상단Bar = 단기상단Bar + 1;
단기하단Bar = 단기하단Bar + 1;
중기상단Bar = 중기상단Bar + 1;
중기하단Bar = 중기하단Bar + 1;
장기상단Bar = 장기상단Bar + 1;
장기하단Bar = 장기하단Bar + 1;
고점표시=(O[n]+C[n])/2;
저점표시=(O[n]+C[n])/2;
#==========================================#
# 단기 파동선 계산
#==========================================#
# 전고점(Peak) 계산
#------------------------------------------#
//Highest(H,2)[3] <= H[2] and H[2] > Highest(H,2)
if Highest(H,n)[n+1] <= H[n] and H[n] > Highest(H,n) then {
if 미완성사용 == 1 then {
for j = 48 downto 1 {
고[j+1] = 고[j];
고Bar[j+1] = 고Bar[j];
}
고[1] = H[n];
고Bar[1] = n;
고점갱신 = True;
고점표시 = 고[1]*1.005;
if 저Bar[1] > 고Bar[2] then {
for j = 48 downto 1 {
저[j+1] = 저[j];
저Bar[j+1] = 저Bar[j];
}
k = n + 1;
for j = n + 2 to 고Bar[2]-1 {
if L[k] > L[j] then k = j;
}
저[1] = L[k];
저Bar[1] = k;
}
}
if 미완성사용 == 0 then {
if 고Bar[1] > 저Bar[1] then {
for j = 48 downto 1 {
고[j+1] = 고[j];
고Bar[j+1] = 고Bar[j];
}
}
if 고Bar[1] > 저Bar[1] or 고[1] <= H[n] then {
고[1] = H[n];
고Bar[1] = n;
고점갱신 = True;
고점표시 = 고[1]*1.005;
}
}
}
#------------------------------------------#
# 전저점(Trough) 계산
#------------------------------------------#
//Lowest(L,2)[3] >= L[2] and L[2] < Lowest(L,2)
if Lowest(L,n)[n+1] >= L[n] and L[n] < Lowest(L,n) then {
if 미완성사용 == 1 then {
for j = 48 downto 1 {
저[j+1] = 저[j];
저Bar[j+1] = 저Bar[j];
}
저[1] = L[n];
저Bar[1] = n;
저점갱신 = True;
저점표시 = 저[1]*0.995;
if 고Bar[1] > 저Bar[2] then {
for j = 48 downto 1 {
고[j+1] = 고[j];
고Bar[j+1] = 고Bar[j];
}
k = n + 1;
for j = n + 2 to 저Bar[2]-1 {
if H[k] < H[j] then k = j;
}
고[1] = H[k];
고Bar[1] = k;
}
}
if 미완성사용 == 0 then {
if 저Bar[1] > 고Bar[1] then {
for j = 48 downto 1 {
저[j+1] = 저[j];
저Bar[j+1] = 저Bar[j];
}
}
if 저Bar[1] > 고Bar[1] or 저[1] >= L[n] then {
저[1] = L[n];
저Bar[1] = n;
저점갱신 = True;
저점표시 = 저[1]*0.995;
}
}
}
#==========================================#
# 중기 파동선 계산
#==========================================#
# 중기고점 계산
#------------------------------------------#
//단기 고점이 발생한 다음 꼭지점을 찾아 중기고점으로 설정
if 고점갱신 == True and 고[3] < 고[2] and 고[2] > 고[1] then { //↗↘
if 미완성사용 == 1 then {
for j = 18 downto 1 {
중기고[j+1] = 중기고[j];
중기고Bar[j+1] = 중기고Bar[j];
}
중기고[1] = 고[2];
중기고Bar[1] = 고Bar[2];
중기고점갱신 = True;
if 중기저Bar[1] > 중기고Bar[2] then {
for j = 18 downto 1 {
중기저[j+1] = 중기저[j];
중기저Bar[j+1] = 중기저Bar[j];
}
k = 2;
for j = 3 to 19 {
if 중기고Bar[2] > 저Bar[j] and
저[k] > 저[j] then {
k = j;
}
}
중기저[1] = 저[k];
중기저Bar[1] = 저Bar[k];
}
}
if 미완성사용 == 0 then {
if 중기고Bar[1] > 중기저Bar[1] then {
for j = 18 downto 1 {
중기고[j+1] = 중기고[j];
중기고Bar[j+1] = 중기고Bar[j];
}
}
if 중기고Bar[1] > 중기저Bar[1] or 중기고[1] <= 고[2] then {
중기고[1] = 고[2];
중기고Bar[1] = 고Bar[2];
중기고점갱신 = True;
}
}
고점갱신 = False;
중기추세갱신 = 상단;
}
#------------------------------------------#
# 중기저점 계산
#------------------------------------------#
//단기 저점이 발생한 다음 꼭지점을 찾아 중기저점으로 설정
if 저점갱신 == True and 저[3] > 저[2] and 저[2] < 저[1] then {
if 미완성사용 == 1 then {
for j = 18 downto 1 {
중기저[j+1] = 중기저[j];
중기저Bar[j+1] = 중기저Bar[j];
}
중기저[1] = 저[2];
중기저Bar[1] = 저Bar[2];
중기저점갱신 = True;
if 중기고Bar[1] > 중기저Bar[2] then {
for j = 18 downto 1 {
중기고[j+1] = 중기고[j];
중기고Bar[j+1] = 중기고Bar[j];
}
k = 2;
for j = 3 to 19 {
if 중기저Bar[2] > 고Bar[j] and
고[k] < 고[j] then {
k = j;
}
}
중기고[1] = 고[k];
중기고Bar[1] = 고Bar[k];
}
}
if 미완성사용 == 0 then {
if 중기저Bar[1] > 중기고Bar[1] then {
for j = 18 downto 1 {
중기저[j+1] = 중기저[j];
중기저Bar[j+1] = 중기저Bar[j];
}
}
if 중기저Bar[1] > 중기고Bar[1] or 중기저[1] >= 저[2] then {
중기저[1] = 저[2];
중기저Bar[1] = 저Bar[2];
중기저점갱신 = True;
}
}
저점갱신 = False;
중기추세갱신 = 하단;
}
#==========================================#
# 장기 파동선 계산
#==========================================#
# 장기고점 계산
#------------------------------------------#
//중기 고점이 발생한 다음 꼭지점을 찾아 장기고점으로 설정
if 중기고점갱신 == True and 중기고[3] < 중기고[2] and
중기고[2] > 중기고[1] then {
if 미완성사용 == 1 then {
for j = 18 downto 1 {
장기고[j+1] = 장기고[j];
장기고Bar[j+1] = 장기고Bar[j];
}
장기고[1] = 중기고[2];
장기고Bar[1] = 중기고Bar[2];
if 장기저Bar[1] > 장기고Bar[2] then {
for j = 18 downto 1 {
장기저[j+1] = 장기저[j];
장기저Bar[j+1] = 장기저Bar[j];
}
k = 2;
for j = 3 to 19 {
if 장기고Bar[2] > 중기저Bar[j] and
중기저[k] > 중기저[j] then {
k = j;
}
}
장기저[1] = 중기저[k];
장기저Bar[1] = 중기저Bar[k];
}
}
if 미완성사용 == 0 then {
if 장기고Bar[1] > 장기저Bar[1] then {
for j = 18 downto 1 {
장기고[j+1] = 장기고[j];
장기고Bar[j+1] = 장기고Bar[j];
}
}
if 장기고Bar[1] > 장기저Bar[1] or 장기고[1] <= 중기고[2] then {
장기고[1] = 중기고[2];
장기고Bar[1] = 중기고Bar[2];
}
}
중기고점갱신 = False;
장기추세갱신 = 상단;
}
#------------------------------------------#
# 장기저점 계산
#------------------------------------------#
//중기 저점이 발생한 다음 꼭지점을 찾아 장기저점으로 설정
if 중기저점갱신 == True and 중기저[3] > 중기저[2] and
중기저[2] < 중기저[1] then {
if 미완성사용 == 1 then {
for j = 18 downto 1 {
장기저[j+1] = 장기저[j];
장기저Bar[j+1] = 장기저Bar[j];
}
장기저[1] = 중기저[2];
장기저Bar[1] = 중기저Bar[2];
if 장기고Bar[1] > 장기저Bar[2] then {
for j = 18 downto 1 {
장기고[j+1] = 장기고[j];
장기고Bar[j+1] = 장기고Bar[j];
}
k = 2;
for j = 3 to 19 {
if 장기저Bar[2] > 중기고Bar[j] and
중기고[k] < 중기고[j] then {
k = j;
}
}
장기고[1] = 중기고[k];
장기고Bar[1] = 중기고Bar[k];
}
}
if 미완성사용 == 0 then {
if 장기저Bar[1] > 장기고Bar[1] then {
for j = 18 downto 1 {
장기저[j+1] = 장기저[j];
장기저Bar[j+1] = 장기저Bar[j];
}
}
if 장기저Bar[1] > 장기고Bar[1] or 장기저[1] >= 중기저[2] then {
장기저[1] = 중기저[2];
장기저Bar[1] = 중기저Bar[2];
}
}
중기저점갱신 = False;
장기추세갱신 = 하단;
}
#==========================================#
# 자동추세선 계산
#==========================================#
if 고Bar[1] == n then {
단기상단채널 = 0;
단기상단기울기 = 0;
for j = 2 to 49 {
if 고[1] < 고[j] and 단기상단기울기 == 0 then {
단기상단기울기 =((고[1]-고[j])/(고Bar[j]-고Bar[1]));
단기상단Bar = 고Bar[j];
단기상단절편 = 고[j];
j = Exit;
}
else if 고[j] <= 0 then j = Exit;
}
}
if 저Bar[1] == n then {
단기하단채널 = 0;
단기하단기울기 = 0;
for j = 2 to 49 {
if 저[1] > 저[j] and 단기하단기울기 == 0 then {
단기하단기울기 = ((저[1]-저[j])/(저Bar[j]-저Bar[1]));
단기하단Bar = 저Bar[j];
단기하단절편 = 저[j];
j = Exit;
}
else if 저[j] <= 0 then j = Exit;
}
}
if 중기추세갱신 == 상단 then {
중기상단채널 = 0;
중기상단기울기 = 0;
for j = 2 to 19 {
if 중기고[1] < 중기고[j] and 중기상단기울기 == 0 then {
중기상단기울기 =
((중기고[1]-중기고[j])/(중기고Bar[j]-중기고Bar[1]));
중기상단Bar = 중기고Bar[j];
중기상단절편 = 중기고[j];
j = Exit;
}
else if 중기고[j] <= 0 then j = Exit;
}
중기추세갱신 = 0;
}
if 중기추세갱신 == 하단 then {
중기하단채널 = 0;
중기하단기울기 = 0;
for j = 2 to 19 {
if 중기저[1] > 중기저[j] and 중기하단기울기 == 0 then {
중기하단기울기 =
((중기저[1]-중기저[j])/(중기저Bar[j]-중기저Bar[1]));
중기하단Bar = 중기저Bar[j];
중기하단절편 = 중기저[j];
j = Exit;
}
else if 중기저[j] <= 0 then j = Exit;
}
중기추세갱신 = 0;
}
if 장기추세갱신 == 상단 then {
장기상단채널 = 0;
장기상단기울기 = 0;
for j = 2 to 19 {
if 장기고[1] < 장기고[j] and 장기상단기울기 == 0 then {
장기상단기울기 =
((장기고[1]-장기고[j])/(장기고Bar[j]-장기고Bar[1]));
장기상단Bar = 장기고Bar[j];
장기상단절편 = 장기고[j];
j = Exit;
}
else if 장기고[j] <= 0 then j = Exit;
}
장기추세갱신 = 0;
}
if 장기추세갱신 == 하단 then {
장기하단채널 = 0;
장기하단기울기 = 0;
for j = 2 to 19 {
if 장기저[1] > 장기저[j] and 장기하단기울기 == 0 then {
장기하단기울기 =
((장기저[1]-장기저[j])/(장기저Bar[j]-장기저Bar[1]));
장기하단Bar = 장기저Bar[j];
장기하단절편 = 장기저[j];
j = Exit;
}
else if 장기저[j] <= 0 then j = Exit;
}
장기추세갱신 = 0;
}
if 단기상단기울기 < 0 then
단기상단채널 = 단기상단기울기 * 단기상단Bar + 단기상단절편;
if 단기하단기울기 > 0 then
단기하단채널 = 단기하단기울기 * 단기하단Bar + 단기하단절편;
if 중기상단기울기 < 0 then
중기상단채널 = 중기상단기울기 * 중기상단Bar + 중기상단절편;
if 중기하단기울기 > 0 then
중기하단채널 = 중기하단기울기 * 중기하단Bar + 중기하단절편;
if 장기상단기울기 < 0 then
장기상단채널 = 장기상단기울기 * 장기상단Bar + 장기상단절편;
if 장기하단기울기 > 0 then
장기하단채널 = 장기하단기울기 * 장기하단Bar + 장기하단절편;
if crossup(c,단기상단채널) Then
buy();
if CrossDown(c,단기하단채널) Then
exitlong();
답변 1
예스스탁 예스스탁 답변
2015-04-06 13:19:33
안녕하세요
예스스탁입니다.
Input:n(5),미완성사용(1);
Var:q(0),k(0),상단(200),하단(100),고점표시(0),저점표시(0),Exit(100),
고점갱신(False),저점갱신(False),중기고점갱신(False),중기저점갱신(False),
중기추세갱신(0),장기추세갱신(0),
단기상단기울기(0),단기상단Bar(0),단기상단절편(0),단기하단기울기(0),
단기하단Bar(0),단기하단절편(0),
중기상단기울기(0),중기상단Bar(0),중기상단절편(0),중기하단기울기(0),
중기하단Bar(0),중기하단절편(0),
장기상단기울기(0),장기상단Bar(0),장기상단절편(0),장기하단기울기(0),
장기하단Bar(0),장기하단절편(0),
단기상단채널(0),단기하단채널(0),중기상단채널(0),중기하단채널(0),
장기상단채널(0),장기하단채널(0);
Array:고[50](0),저[50](0),고Bar[50](0),저Bar[50](0),
중기고[20](0),중기저[20](0),중기고Bar[20](0),중기저Bar[20](0),
장기고[20](0),장기저[20](0),장기고Bar[20](0),장기저Bar[20](0);
Input:length(5);
Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0);
Array:valArr[10](0),barArr[10](0),turnPntArr[10]("");
#==========================================#
# 초기처리 (Initialize Routine)
#==========================================#
for j = 1 to 19 {
고Bar[j] = 고Bar[j] + 1;
저Bar[j] = 저Bar[j] + 1;
중기고Bar[j] = 중기고Bar[j] + 1;
중기저Bar[j] = 중기저Bar[j] + 1;
장기고Bar[j] = 장기고Bar[j] + 1;
장기저Bar[j] = 장기저Bar[j] + 1;
}
for j = 20 to 49 {
고Bar[j] = 고Bar[j] + 1;
저Bar[j] = 저Bar[j] + 1;
}
단기상단Bar = 단기상단Bar + 1;
단기하단Bar = 단기하단Bar + 1;
중기상단Bar = 중기상단Bar + 1;
중기하단Bar = 중기하단Bar + 1;
장기상단Bar = 장기상단Bar + 1;
장기하단Bar = 장기하단Bar + 1;
고점표시=(O[n]+C[n])/2;
저점표시=(O[n]+C[n])/2;
#==========================================#
# 단기 파동선 계산
#==========================================#
# 전고점(Peak) 계산
#------------------------------------------#
//Highest(H,2)[3] <= H[2] and H[2] > Highest(H,2)
if Highest(H,n)[n+1] <= H[n] and H[n] > Highest(H,n) then {
if 미완성사용 == 1 then {
for j = 48 downto 1 {
고[j+1] = 고[j];
고Bar[j+1] = 고Bar[j];
}
고[1] = H[n];
고Bar[1] = n;
고점갱신 = True;
고점표시 = 고[1]*1.005;
if 저Bar[1] > 고Bar[2] then {
for j = 48 downto 1 {
저[j+1] = 저[j];
저Bar[j+1] = 저Bar[j];
}
k = n + 1;
for j = n + 2 to 고Bar[2]-1 {
if L[k] > L[j] then k = j;
}
저[1] = L[k];
저Bar[1] = k;
}
}
if 미완성사용 == 0 then {
if 고Bar[1] > 저Bar[1] then {
for j = 48 downto 1 {
고[j+1] = 고[j];
고Bar[j+1] = 고Bar[j];
}
}
if 고Bar[1] > 저Bar[1] or 고[1] <= H[n] then {
고[1] = H[n];
고Bar[1] = n;
고점갱신 = True;
고점표시 = 고[1]*1.005;
}
}
}
#------------------------------------------#
# 전저점(Trough) 계산
#------------------------------------------#
//Lowest(L,2)[3] >= L[2] and L[2] < Lowest(L,2)
if Lowest(L,n)[n+1] >= L[n] and L[n] < Lowest(L,n) then {
if 미완성사용 == 1 then {
for j = 48 downto 1 {
저[j+1] = 저[j];
저Bar[j+1] = 저Bar[j];
}
저[1] = L[n];
저Bar[1] = n;
저점갱신 = True;
저점표시 = 저[1]*0.995;
if 고Bar[1] > 저Bar[2] then {
for j = 48 downto 1 {
고[j+1] = 고[j];
고Bar[j+1] = 고Bar[j];
}
k = n + 1;
for j = n + 2 to 저Bar[2]-1 {
if H[k] < H[j] then k = j;
}
고[1] = H[k];
고Bar[1] = k;
}
}
if 미완성사용 == 0 then {
if 저Bar[1] > 고Bar[1] then {
for j = 48 downto 1 {
저[j+1] = 저[j];
저Bar[j+1] = 저Bar[j];
}
}
if 저Bar[1] > 고Bar[1] or 저[1] >= L[n] then {
저[1] = L[n];
저Bar[1] = n;
저점갱신 = True;
저점표시 = 저[1]*0.995;
}
}
}
#==========================================#
# 중기 파동선 계산
#==========================================#
# 중기고점 계산
#------------------------------------------#
//단기 고점이 발생한 다음 꼭지점을 찾아 중기고점으로 설정
if 고점갱신 == True and 고[3] < 고[2] and 고[2] > 고[1] then { //↗↘
if 미완성사용 == 1 then {
for j = 18 downto 1 {
중기고[j+1] = 중기고[j];
중기고Bar[j+1] = 중기고Bar[j];
}
중기고[1] = 고[2];
중기고Bar[1] = 고Bar[2];
중기고점갱신 = True;
if 중기저Bar[1] > 중기고Bar[2] then {
for j = 18 downto 1 {
중기저[j+1] = 중기저[j];
중기저Bar[j+1] = 중기저Bar[j];
}
k = 2;
for j = 3 to 19 {
if 중기고Bar[2] > 저Bar[j] and
저[k] > 저[j] then {
k = j;
}
}
중기저[1] = 저[k];
중기저Bar[1] = 저Bar[k];
}
}
if 미완성사용 == 0 then {
if 중기고Bar[1] > 중기저Bar[1] then {
for j = 18 downto 1 {
중기고[j+1] = 중기고[j];
중기고Bar[j+1] = 중기고Bar[j];
}
}
if 중기고Bar[1] > 중기저Bar[1] or 중기고[1] <= 고[2] then {
중기고[1] = 고[2];
중기고Bar[1] = 고Bar[2];
중기고점갱신 = True;
}
}
고점갱신 = False;
중기추세갱신 = 상단;
}
#------------------------------------------#
# 중기저점 계산
#------------------------------------------#
//단기 저점이 발생한 다음 꼭지점을 찾아 중기저점으로 설정
if 저점갱신 == True and 저[3] > 저[2] and 저[2] < 저[1] then {
if 미완성사용 == 1 then {
for j = 18 downto 1 {
중기저[j+1] = 중기저[j];
중기저Bar[j+1] = 중기저Bar[j];
}
중기저[1] = 저[2];
중기저Bar[1] = 저Bar[2];
중기저점갱신 = True;
if 중기고Bar[1] > 중기저Bar[2] then {
for j = 18 downto 1 {
중기고[j+1] = 중기고[j];
중기고Bar[j+1] = 중기고Bar[j];
}
k = 2;
for j = 3 to 19 {
if 중기저Bar[2] > 고Bar[j] and
고[k] < 고[j] then {
k = j;
}
}
중기고[1] = 고[k];
중기고Bar[1] = 고Bar[k];
}
}
if 미완성사용 == 0 then {
if 중기저Bar[1] > 중기고Bar[1] then {
for j = 18 downto 1 {
중기저[j+1] = 중기저[j];
중기저Bar[j+1] = 중기저Bar[j];
}
}
if 중기저Bar[1] > 중기고Bar[1] or 중기저[1] >= 저[2] then {
중기저[1] = 저[2];
중기저Bar[1] = 저Bar[2];
중기저점갱신 = True;
}
}
저점갱신 = False;
중기추세갱신 = 하단;
}
#==========================================#
# 장기 파동선 계산
#==========================================#
# 장기고점 계산
#------------------------------------------#
//중기 고점이 발생한 다음 꼭지점을 찾아 장기고점으로 설정
if 중기고점갱신 == True and 중기고[3] < 중기고[2] and
중기고[2] > 중기고[1] then {
if 미완성사용 == 1 then {
for j = 18 downto 1 {
장기고[j+1] = 장기고[j];
장기고Bar[j+1] = 장기고Bar[j];
}
장기고[1] = 중기고[2];
장기고Bar[1] = 중기고Bar[2];
if 장기저Bar[1] > 장기고Bar[2] then {
for j = 18 downto 1 {
장기저[j+1] = 장기저[j];
장기저Bar[j+1] = 장기저Bar[j];
}
k = 2;
for j = 3 to 19 {
if 장기고Bar[2] > 중기저Bar[j] and
중기저[k] > 중기저[j] then {
k = j;
}
}
장기저[1] = 중기저[k];
장기저Bar[1] = 중기저Bar[k];
}
}
if 미완성사용 == 0 then {
if 장기고Bar[1] > 장기저Bar[1] then {
for j = 18 downto 1 {
장기고[j+1] = 장기고[j];
장기고Bar[j+1] = 장기고Bar[j];
}
}
if 장기고Bar[1] > 장기저Bar[1] or 장기고[1] <= 중기고[2] then {
장기고[1] = 중기고[2];
장기고Bar[1] = 중기고Bar[2];
}
}
중기고점갱신 = False;
장기추세갱신 = 상단;
}
#------------------------------------------#
# 장기저점 계산
#------------------------------------------#
//중기 저점이 발생한 다음 꼭지점을 찾아 장기저점으로 설정
if 중기저점갱신 == True and 중기저[3] > 중기저[2] and
중기저[2] < 중기저[1] then {
if 미완성사용 == 1 then {
for j = 18 downto 1 {
장기저[j+1] = 장기저[j];
장기저Bar[j+1] = 장기저Bar[j];
}
장기저[1] = 중기저[2];
장기저Bar[1] = 중기저Bar[2];
if 장기고Bar[1] > 장기저Bar[2] then {
for j = 18 downto 1 {
장기고[j+1] = 장기고[j];
장기고Bar[j+1] = 장기고Bar[j];
}
k = 2;
for j = 3 to 19 {
if 장기저Bar[2] > 중기고Bar[j] and
중기고[k] < 중기고[j] then {
k = j;
}
}
장기고[1] = 중기고[k];
장기고Bar[1] = 중기고Bar[k];
}
}
if 미완성사용 == 0 then {
if 장기저Bar[1] > 장기고Bar[1] then {
for j = 18 downto 1 {
장기저[j+1] = 장기저[j];
장기저Bar[j+1] = 장기저Bar[j];
}
}
if 장기저Bar[1] > 장기고Bar[1] or 장기저[1] >= 중기저[2] then {
장기저[1] = 중기저[2];
장기저Bar[1] = 중기저Bar[2];
}
}
중기저점갱신 = False;
장기추세갱신 = 하단;
}
#==========================================#
# 자동추세선 계산
#==========================================#
if 고Bar[1] == n then {
단기상단채널 = 0;
단기상단기울기 = 0;
for j = 2 to 49 {
if 고[1] < 고[j] and 단기상단기울기 == 0 then {
단기상단기울기 =((고[1]-고[j])/(고Bar[j]-고Bar[1]));
단기상단Bar = 고Bar[j];
단기상단절편 = 고[j];
j = Exit;
}
else if 고[j] <= 0 then j = Exit;
}
}
if 저Bar[1] == n then {
단기하단채널 = 0;
단기하단기울기 = 0;
for j = 2 to 49 {
if 저[1] > 저[j] and 단기하단기울기 == 0 then {
단기하단기울기 = ((저[1]-저[j])/(저Bar[j]-저Bar[1]));
단기하단Bar = 저Bar[j];
단기하단절편 = 저[j];
j = Exit;
}
else if 저[j] <= 0 then j = Exit;
}
}
if 중기추세갱신 == 상단 then {
중기상단채널 = 0;
중기상단기울기 = 0;
for j = 2 to 19 {
if 중기고[1] < 중기고[j] and 중기상단기울기 == 0 then {
중기상단기울기 =
((중기고[1]-중기고[j])/(중기고Bar[j]-중기고Bar[1]));
중기상단Bar = 중기고Bar[j];
중기상단절편 = 중기고[j];
j = Exit;
}
else if 중기고[j] <= 0 then j = Exit;
}
중기추세갱신 = 0;
}
if 중기추세갱신 == 하단 then {
중기하단채널 = 0;
중기하단기울기 = 0;
for j = 2 to 19 {
if 중기저[1] > 중기저[j] and 중기하단기울기 == 0 then {
중기하단기울기 =
((중기저[1]-중기저[j])/(중기저Bar[j]-중기저Bar[1]));
중기하단Bar = 중기저Bar[j];
중기하단절편 = 중기저[j];
j = Exit;
}
else if 중기저[j] <= 0 then j = Exit;
}
중기추세갱신 = 0;
}
if 장기추세갱신 == 상단 then {
장기상단채널 = 0;
장기상단기울기 = 0;
for j = 2 to 19 {
if 장기고[1] < 장기고[j] and 장기상단기울기 == 0 then {
장기상단기울기 =
((장기고[1]-장기고[j])/(장기고Bar[j]-장기고Bar[1]));
장기상단Bar = 장기고Bar[j];
장기상단절편 = 장기고[j];
j = Exit;
}
else if 장기고[j] <= 0 then j = Exit;
}
장기추세갱신 = 0;
}
if 장기추세갱신 == 하단 then {
장기하단채널 = 0;
장기하단기울기 = 0;
for j = 2 to 19 {
if 장기저[1] > 장기저[j] and 장기하단기울기 == 0 then {
장기하단기울기 =
((장기저[1]-장기저[j])/(장기저Bar[j]-장기저Bar[1]));
장기하단Bar = 장기저Bar[j];
장기하단절편 = 장기저[j];
j = Exit;
}
else if 장기저[j] <= 0 then j = Exit;
}
장기추세갱신 = 0;
}
if 단기상단기울기 < 0 then
단기상단채널 = 단기상단기울기 * 단기상단Bar + 단기상단절편;
if 단기하단기울기 > 0 then
단기하단채널 = 단기하단기울기 * 단기하단Bar + 단기하단절편;
if 중기상단기울기 < 0 then
중기상단채널 = 중기상단기울기 * 중기상단Bar + 중기상단절편;
if 중기하단기울기 > 0 then
중기하단채널 = 중기하단기울기 * 중기하단Bar + 중기하단절편;
if 장기상단기울기 < 0 then
장기상단채널 = 장기상단기울기 * 장기상단Bar + 장기상단절편;
if 장기하단기울기 > 0 then
장기하단채널 = 장기하단기울기 * 장기하단Bar + 장기하단절편;
For j = 0 To 9
{
barArr[j] = barArr[j] + 1;
}
Condition1 = Highest(H,length) == H and lastHiVal <> H;
Condition2 = Lowest(L,length) == L and lastLoVal <> L;
If Condition1 Then lastHiVal = H;
If Condition2 Then lastLoVal = L;
turnPntBit = "";
If Condition1 and Condition2 Then
{
If Max(valArr[1],valArr[2]) < H and Min(valArr[1],valArr[2]) > L Then
turnPntBit = "HiLo";
Else If Max(valArr[1],valArr[2]) < H Then turnPntBit = "Hi";
Else If Min(valArr[1],valArr[2]) > L Then turnPntBit = "Lo";
}
Else If Condition1 Then turnPntBit = "Hi";
Else If Condition2 Then turnPntBit = "Lo";
If turnPntBit <> "" Then
{
If turnPntBit == "HiLo" Then
{
valArr[1] = IFF(turnPntArr[1] == "Hi",H,L);
barArr[1] = 0;
TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]);
If turnPntArr[1] == "Hi" Then
turnPntBit = "Lo";
Else
turnPntBit = "Hi";
}
If turnPntBit <> turnPntArr[1] Then
{
for j = 8 downto 1
{
valArr[j+1] = valArr[j];
barArr[j+1] = barArr[j];
turnPntArr[j+1] = turnPntArr[j];
}
}
If turnPntBit <> turnPntArr[1] or
(turnPntBit == turnPntArr[1] and
((turnPntBit == "Hi" and valArr[1] < H) or
(turnPntBit == "Lo" and valArr[1] > L))) Then
{
valArr[1] = IFF(turnPntBit == "Hi",H,L);
barArr[1] = 0;
turnPntArr[1] = turnPntBit;
If turnPntArr[1][1] <> turnPntArr[1][0] Then{
TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]);
if turnPntArr[1] == "Hi" and crossup(c,단기상단채널) Then
buy();
if turnPntArr[1] == "Lo" and CrossDown(c,단기하단채널) Then
sell();
}
Else
TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]);
}
}
즐거운 하루되세요
> NH_mo****** 님이 쓴 글입니다.
> 제목 : 복합시스템식 부탁합니다
> 지그재그패턴과
중단기추세의
신호가 동시에
발생하는 캔들을
시스템식으로
만들어주세요.
다음은 시스템식입니다
지그재그패턴=
Input:length(5);
Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0);
Array:valArr[10](0),barArr[10](0),turnPntArr[10]("");
// 봉이 새로 생겼으므로 봉개수 관리하는 변수들의 봉개수 값 1씩 증가
For j = 0 To 9
{
barArr[j] = barArr[j] + 1;
}
// 고점조건 = 현재 봉의 고가가 기간최고가이면서 최고가 갱신되었을 때;
// 저점조건 = 현재 봉의 저가가 기간최저가이면서 최저가 갱신되었을 때;
// 고점,저점조건 만족시 현재 봉의 고[저]가를 변수에 저장
Condition1 = Highest(H,length) == H and lastHiVal <> H;
Condition2 = Lowest(L,length) == L and lastLoVal <> L;
If Condition1 Then lastHiVal = H;
If Condition2 Then lastLoVal = L;
// 전환점구분 null값으로 초기화;
turnPntBit = "";
// if 고점조건, 저점조건 동시 만족시 then
// if 이전 고점,저점 범위를 모두 벗어났을 때
// 전환점구분 = 고저점;
// else if 이전 고점을 갱신했다면 전환점구분 = 고점;
// else if 이전 저점을 갱신했다면 전환점구분 = 저점;
// else if 고점조건 만족하면 전환점구분 = 고점;
// else if 저점조건 만족하면 전환점구분 = 저점;
If Condition1 and Condition2 Then
{
If Max(valArr[1],valArr[2]) < H and Min(valArr[1],valArr[2]) > L Then
turnPntBit = "HiLo";
Else If Max(valArr[1],valArr[2]) < H Then turnPntBit = "Hi";
Else If Min(valArr[1],valArr[2]) > L Then turnPntBit = "Lo";
}
Else If Condition1 Then turnPntBit = "Hi";
Else If Condition2 Then turnPntBit = "Lo";
// if 전환점구분에 값이 있을 때만 then 아래 실행, 없으면 통과
If turnPntBit <> "" Then
{
// if 전환점구분이 고저점이면 then
// 이전 파동은 연장시키고 아래에서 새로이 파동선을 추가토록 한다.
If turnPntBit == "HiLo" Then
{
valArr[1] = IFF(turnPntArr[1] == "Hi",H,L);
barArr[1] = 0;
TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]);
If turnPntArr[1] == "Hi" Then
turnPntBit = "Lo";
Else
turnPntBit = "Hi";
}
// if 신규 전환점구분이 현재(전환점배열 1번째)와 다르면 then
// 배열값들을 이전값으로 Move;
If turnPntBit <> turnPntArr[1] Then
{
for j = 8 downto 1
{
valArr[j+1] = valArr[j];
barArr[j+1] = barArr[j];
turnPntArr[j+1] = turnPntArr[j];
}
}
// if 전환점구분이 바뀌었거나 또는
// (전환점구분은 안바뀌었는데
// (이전 고점보다 높은 고점이 발생했거나 또는
// 이전 저점보다 낮은 저점이 발생했으면)) then
If turnPntBit <> turnPntArr[1] or
(turnPntBit == turnPntArr[1] and
((turnPntBit == "Hi" and valArr[1] < H) or
(turnPntBit == "Lo" and valArr[1] > L))) Then
{
// 값 배열에는 고점 또는 저점을 대입;
// 봉개수 배열에는 0값 대입;
// 전환점 배열에 전환점구분값을 대입;
valArr[1] = IFF(turnPntBit == "Hi",H,L);
barArr[1] = 0;
turnPntArr[1] = turnPntBit;
// if 이전봉대비 전환점구분이 바뀌었다면 추세선 새로 그리고;
// else 전환점구분이 안바뀌었으면 값만 바뀐거므로 추세선 연장;
If turnPntArr[1][1] <> turnPntArr[1][0] Then{
TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2],sDate[barArr[1]],sTime[barArr[1]],valArr[1]);
if turnPntArr[1] == "Hi" Then
buy();
if turnPntArr[1] == "Lo" Then
sell();
}
Else
TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]);
}
}
중단기추세=
Input:n(5),미완성사용(1);
Var:j(0),q(0),k(0),상단(200),하단(100),고점표시(0),저점표시(0),Exit(100),
고점갱신(False),저점갱신(False),중기고점갱신(False),중기저점갱신(False),
중기추세갱신(0),장기추세갱신(0),
단기상단기울기(0),단기상단Bar(0),단기상단절편(0),단기하단기울기(0),
단기하단Bar(0),단기하단절편(0),
중기상단기울기(0),중기상단Bar(0),중기상단절편(0),중기하단기울기(0),
중기하단Bar(0),중기하단절편(0),
장기상단기울기(0),장기상단Bar(0),장기상단절편(0),장기하단기울기(0),
장기하단Bar(0),장기하단절편(0),
단기상단채널(0),단기하단채널(0),중기상단채널(0),중기하단채널(0),
장기상단채널(0),장기하단채널(0);
Array:고[50](0),저[50](0),고Bar[50](0),저Bar[50](0),
중기고[20](0),중기저[20](0),중기고Bar[20](0),중기저Bar[20](0),
장기고[20](0),장기저[20](0),장기고Bar[20](0),장기저Bar[20](0);
#==========================================#
# 초기처리 (Initialize Routine)
#==========================================#
for j = 1 to 19 {
고Bar[j] = 고Bar[j] + 1;
저Bar[j] = 저Bar[j] + 1;
중기고Bar[j] = 중기고Bar[j] + 1;
중기저Bar[j] = 중기저Bar[j] + 1;
장기고Bar[j] = 장기고Bar[j] + 1;
장기저Bar[j] = 장기저Bar[j] + 1;
}
for j = 20 to 49 {
고Bar[j] = 고Bar[j] + 1;
저Bar[j] = 저Bar[j] + 1;
}
단기상단Bar = 단기상단Bar + 1;
단기하단Bar = 단기하단Bar + 1;
중기상단Bar = 중기상단Bar + 1;
중기하단Bar = 중기하단Bar + 1;
장기상단Bar = 장기상단Bar + 1;
장기하단Bar = 장기하단Bar + 1;
고점표시=(O[n]+C[n])/2;
저점표시=(O[n]+C[n])/2;
#==========================================#
# 단기 파동선 계산
#==========================================#
# 전고점(Peak) 계산
#------------------------------------------#
//Highest(H,2)[3] <= H[2] and H[2] > Highest(H,2)
if Highest(H,n)[n+1] <= H[n] and H[n] > Highest(H,n) then {
if 미완성사용 == 1 then {
for j = 48 downto 1 {
고[j+1] = 고[j];
고Bar[j+1] = 고Bar[j];
}
고[1] = H[n];
고Bar[1] = n;
고점갱신 = True;
고점표시 = 고[1]*1.005;
if 저Bar[1] > 고Bar[2] then {
for j = 48 downto 1 {
저[j+1] = 저[j];
저Bar[j+1] = 저Bar[j];
}
k = n + 1;
for j = n + 2 to 고Bar[2]-1 {
if L[k] > L[j] then k = j;
}
저[1] = L[k];
저Bar[1] = k;
}
}
if 미완성사용 == 0 then {
if 고Bar[1] > 저Bar[1] then {
for j = 48 downto 1 {
고[j+1] = 고[j];
고Bar[j+1] = 고Bar[j];
}
}
if 고Bar[1] > 저Bar[1] or 고[1] <= H[n] then {
고[1] = H[n];
고Bar[1] = n;
고점갱신 = True;
고점표시 = 고[1]*1.005;
}
}
}
#------------------------------------------#
# 전저점(Trough) 계산
#------------------------------------------#
//Lowest(L,2)[3] >= L[2] and L[2] < Lowest(L,2)
if Lowest(L,n)[n+1] >= L[n] and L[n] < Lowest(L,n) then {
if 미완성사용 == 1 then {
for j = 48 downto 1 {
저[j+1] = 저[j];
저Bar[j+1] = 저Bar[j];
}
저[1] = L[n];
저Bar[1] = n;
저점갱신 = True;
저점표시 = 저[1]*0.995;
if 고Bar[1] > 저Bar[2] then {
for j = 48 downto 1 {
고[j+1] = 고[j];
고Bar[j+1] = 고Bar[j];
}
k = n + 1;
for j = n + 2 to 저Bar[2]-1 {
if H[k] < H[j] then k = j;
}
고[1] = H[k];
고Bar[1] = k;
}
}
if 미완성사용 == 0 then {
if 저Bar[1] > 고Bar[1] then {
for j = 48 downto 1 {
저[j+1] = 저[j];
저Bar[j+1] = 저Bar[j];
}
}
if 저Bar[1] > 고Bar[1] or 저[1] >= L[n] then {
저[1] = L[n];
저Bar[1] = n;
저점갱신 = True;
저점표시 = 저[1]*0.995;
}
}
}
#==========================================#
# 중기 파동선 계산
#==========================================#
# 중기고점 계산
#------------------------------------------#
//단기 고점이 발생한 다음 꼭지점을 찾아 중기고점으로 설정
if 고점갱신 == True and 고[3] < 고[2] and 고[2] > 고[1] then { //↗↘
if 미완성사용 == 1 then {
for j = 18 downto 1 {
중기고[j+1] = 중기고[j];
중기고Bar[j+1] = 중기고Bar[j];
}
중기고[1] = 고[2];
중기고Bar[1] = 고Bar[2];
중기고점갱신 = True;
if 중기저Bar[1] > 중기고Bar[2] then {
for j = 18 downto 1 {
중기저[j+1] = 중기저[j];
중기저Bar[j+1] = 중기저Bar[j];
}
k = 2;
for j = 3 to 19 {
if 중기고Bar[2] > 저Bar[j] and
저[k] > 저[j] then {
k = j;
}
}
중기저[1] = 저[k];
중기저Bar[1] = 저Bar[k];
}
}
if 미완성사용 == 0 then {
if 중기고Bar[1] > 중기저Bar[1] then {
for j = 18 downto 1 {
중기고[j+1] = 중기고[j];
중기고Bar[j+1] = 중기고Bar[j];
}
}
if 중기고Bar[1] > 중기저Bar[1] or 중기고[1] <= 고[2] then {
중기고[1] = 고[2];
중기고Bar[1] = 고Bar[2];
중기고점갱신 = True;
}
}
고점갱신 = False;
중기추세갱신 = 상단;
}
#------------------------------------------#
# 중기저점 계산
#------------------------------------------#
//단기 저점이 발생한 다음 꼭지점을 찾아 중기저점으로 설정
if 저점갱신 == True and 저[3] > 저[2] and 저[2] < 저[1] then {
if 미완성사용 == 1 then {
for j = 18 downto 1 {
중기저[j+1] = 중기저[j];
중기저Bar[j+1] = 중기저Bar[j];
}
중기저[1] = 저[2];
중기저Bar[1] = 저Bar[2];
중기저점갱신 = True;
if 중기고Bar[1] > 중기저Bar[2] then {
for j = 18 downto 1 {
중기고[j+1] = 중기고[j];
중기고Bar[j+1] = 중기고Bar[j];
}
k = 2;
for j = 3 to 19 {
if 중기저Bar[2] > 고Bar[j] and
고[k] < 고[j] then {
k = j;
}
}
중기고[1] = 고[k];
중기고Bar[1] = 고Bar[k];
}
}
if 미완성사용 == 0 then {
if 중기저Bar[1] > 중기고Bar[1] then {
for j = 18 downto 1 {
중기저[j+1] = 중기저[j];
중기저Bar[j+1] = 중기저Bar[j];
}
}
if 중기저Bar[1] > 중기고Bar[1] or 중기저[1] >= 저[2] then {
중기저[1] = 저[2];
중기저Bar[1] = 저Bar[2];
중기저점갱신 = True;
}
}
저점갱신 = False;
중기추세갱신 = 하단;
}
#==========================================#
# 장기 파동선 계산
#==========================================#
# 장기고점 계산
#------------------------------------------#
//중기 고점이 발생한 다음 꼭지점을 찾아 장기고점으로 설정
if 중기고점갱신 == True and 중기고[3] < 중기고[2] and
중기고[2] > 중기고[1] then {
if 미완성사용 == 1 then {
for j = 18 downto 1 {
장기고[j+1] = 장기고[j];
장기고Bar[j+1] = 장기고Bar[j];
}
장기고[1] = 중기고[2];
장기고Bar[1] = 중기고Bar[2];
if 장기저Bar[1] > 장기고Bar[2] then {
for j = 18 downto 1 {
장기저[j+1] = 장기저[j];
장기저Bar[j+1] = 장기저Bar[j];
}
k = 2;
for j = 3 to 19 {
if 장기고Bar[2] > 중기저Bar[j] and
중기저[k] > 중기저[j] then {
k = j;
}
}
장기저[1] = 중기저[k];
장기저Bar[1] = 중기저Bar[k];
}
}
if 미완성사용 == 0 then {
if 장기고Bar[1] > 장기저Bar[1] then {
for j = 18 downto 1 {
장기고[j+1] = 장기고[j];
장기고Bar[j+1] = 장기고Bar[j];
}
}
if 장기고Bar[1] > 장기저Bar[1] or 장기고[1] <= 중기고[2] then {
장기고[1] = 중기고[2];
장기고Bar[1] = 중기고Bar[2];
}
}
중기고점갱신 = False;
장기추세갱신 = 상단;
}
#------------------------------------------#
# 장기저점 계산
#------------------------------------------#
//중기 저점이 발생한 다음 꼭지점을 찾아 장기저점으로 설정
if 중기저점갱신 == True and 중기저[3] > 중기저[2] and
중기저[2] < 중기저[1] then {
if 미완성사용 == 1 then {
for j = 18 downto 1 {
장기저[j+1] = 장기저[j];
장기저Bar[j+1] = 장기저Bar[j];
}
장기저[1] = 중기저[2];
장기저Bar[1] = 중기저Bar[2];
if 장기고Bar[1] > 장기저Bar[2] then {
for j = 18 downto 1 {
장기고[j+1] = 장기고[j];
장기고Bar[j+1] = 장기고Bar[j];
}
k = 2;
for j = 3 to 19 {
if 장기저Bar[2] > 중기고Bar[j] and
중기고[k] < 중기고[j] then {
k = j;
}
}
장기고[1] = 중기고[k];
장기고Bar[1] = 중기고Bar[k];
}
}
if 미완성사용 == 0 then {
if 장기저Bar[1] > 장기고Bar[1] then {
for j = 18 downto 1 {
장기저[j+1] = 장기저[j];
장기저Bar[j+1] = 장기저Bar[j];
}
}
if 장기저Bar[1] > 장기고Bar[1] or 장기저[1] >= 중기저[2] then {
장기저[1] = 중기저[2];
장기저Bar[1] = 중기저Bar[2];
}
}
중기저점갱신 = False;
장기추세갱신 = 하단;
}
#==========================================#
# 자동추세선 계산
#==========================================#
if 고Bar[1] == n then {
단기상단채널 = 0;
단기상단기울기 = 0;
for j = 2 to 49 {
if 고[1] < 고[j] and 단기상단기울기 == 0 then {
단기상단기울기 =((고[1]-고[j])/(고Bar[j]-고Bar[1]));
단기상단Bar = 고Bar[j];
단기상단절편 = 고[j];
j = Exit;
}
else if 고[j] <= 0 then j = Exit;
}
}
if 저Bar[1] == n then {
단기하단채널 = 0;
단기하단기울기 = 0;
for j = 2 to 49 {
if 저[1] > 저[j] and 단기하단기울기 == 0 then {
단기하단기울기 = ((저[1]-저[j])/(저Bar[j]-저Bar[1]));
단기하단Bar = 저Bar[j];
단기하단절편 = 저[j];
j = Exit;
}
else if 저[j] <= 0 then j = Exit;
}
}
if 중기추세갱신 == 상단 then {
중기상단채널 = 0;
중기상단기울기 = 0;
for j = 2 to 19 {
if 중기고[1] < 중기고[j] and 중기상단기울기 == 0 then {
중기상단기울기 =
((중기고[1]-중기고[j])/(중기고Bar[j]-중기고Bar[1]));
중기상단Bar = 중기고Bar[j];
중기상단절편 = 중기고[j];
j = Exit;
}
else if 중기고[j] <= 0 then j = Exit;
}
중기추세갱신 = 0;
}
if 중기추세갱신 == 하단 then {
중기하단채널 = 0;
중기하단기울기 = 0;
for j = 2 to 19 {
if 중기저[1] > 중기저[j] and 중기하단기울기 == 0 then {
중기하단기울기 =
((중기저[1]-중기저[j])/(중기저Bar[j]-중기저Bar[1]));
중기하단Bar = 중기저Bar[j];
중기하단절편 = 중기저[j];
j = Exit;
}
else if 중기저[j] <= 0 then j = Exit;
}
중기추세갱신 = 0;
}
if 장기추세갱신 == 상단 then {
장기상단채널 = 0;
장기상단기울기 = 0;
for j = 2 to 19 {
if 장기고[1] < 장기고[j] and 장기상단기울기 == 0 then {
장기상단기울기 =
((장기고[1]-장기고[j])/(장기고Bar[j]-장기고Bar[1]));
장기상단Bar = 장기고Bar[j];
장기상단절편 = 장기고[j];
j = Exit;
}
else if 장기고[j] <= 0 then j = Exit;
}
장기추세갱신 = 0;
}
if 장기추세갱신 == 하단 then {
장기하단채널 = 0;
장기하단기울기 = 0;
for j = 2 to 19 {
if 장기저[1] > 장기저[j] and 장기하단기울기 == 0 then {
장기하단기울기 =
((장기저[1]-장기저[j])/(장기저Bar[j]-장기저Bar[1]));
장기하단Bar = 장기저Bar[j];
장기하단절편 = 장기저[j];
j = Exit;
}
else if 장기저[j] <= 0 then j = Exit;
}
장기추세갱신 = 0;
}
if 단기상단기울기 < 0 then
단기상단채널 = 단기상단기울기 * 단기상단Bar + 단기상단절편;
if 단기하단기울기 > 0 then
단기하단채널 = 단기하단기울기 * 단기하단Bar + 단기하단절편;
if 중기상단기울기 < 0 then
중기상단채널 = 중기상단기울기 * 중기상단Bar + 중기상단절편;
if 중기하단기울기 > 0 then
중기하단채널 = 중기하단기울기 * 중기하단Bar + 중기하단절편;
if 장기상단기울기 < 0 then
장기상단채널 = 장기상단기울기 * 장기상단Bar + 장기상단절편;
if 장기하단기울기 > 0 then
장기하단채널 = 장기하단기울기 * 장기하단Bar + 장기하단절편;
if crossup(c,단기상단채널) Then
buy();
if CrossDown(c,단기하단채널) Then
exitlong();
다음글