커뮤니티

문의드립니다

프로필 이미지
cjfdk
2026-04-09 11:01:24
556
글번호 231526
답변완료

1번 시스템

input : Period(20),dv(2);

input : 하단아래(3),하단위(4),상단위(3),상단아래(4);

var : BBup(0),BBmd(0),BBdn(0);

var : T(0),i1(0),i2(0),i3(0),i4(0),S(0),value(0);


BBup = BollBandUp(Period,dv);

BBmd = ma(c,Period);

BBdn = BollBandDown(Period,dv);



if CrossDown(C,BBdn) Then

{

T = -1;

i1 = 0;

}


if CrossUp(C,BBdn) Then

{

T = 1;

i2 = 0;

}


if CrossUp(C,BBup) Then

{

T = 2;

i3 = 0;

}


if CrossDown(C,BBup) Then

{

T = -2;

i4 = 0;

}


if T == -1 Then

i1 = i1+1;


if T == 1 Then

i2 = i2+1;


if T == 2 Then

i3 = i3+1;


if T == -2 Then

i4 = i4+1;


if S <= 0 and T == 1 and i2 == 하단위 and i1 >= 하단아래 Then

{

S = 1;

value = c-PriceScale*100;

}



if S >= 0 and T == -2 and i4 == 상단아래 and i3 >= 상단위 Then

{

S = -1;

value = c+PriceScale*100;

}






var : S1(0);




if S == 1 Then

{

if S == S[1] and L <= value Then

S = 0;

}

S1 = 1;


if S == -1 Then

{

if S == S[1] and H >= value Then

S = 0;

}

S1 = -1;









input : short1(6),long1(18),sig1(7);

input : short2(6),long2(21),sig2(7);

input : short3(6),long3(27),sig3(7);

var : macdv1(0),macds1(0);

var : macdv2(0),macds2(0);

var : macdv3(0),macds3(0);


macdv1 = macd(short1,long1);

macds1 = ema(macdv1,sig1);

macdv2 = macd(short2,long2);

macds2 = ema(macdv2,sig2);

macdv3 = macd(short3,long3);

macds3 = ema(macdv3,sig3);



var : S3(0);





if macdv1 < 0 and CrossUp(macdv1,macds1) and

macdv2 < 0 and CrossUp(macdv2,macds2) and

macdv3 < 0 and CrossUp(macdv3,macds3) Then

S3 = 1;


if macdv1 > 0 and CrossUp(macdv1,macds1) and

macdv2 > 0 and CrossUp(macdv2,macds2) and

macdv3 > 0 and CrossUp(macdv3,macds3) Then

S3 = -1;






input : atrMult(4.5);

input : atrlen(12);

input : rsmlen(3);

input : tplen(14);

var : i(0),sum(0),source(0);

var : alpha(0),atrValue1(0),upperLevel(0),lowerLevel(0);

var : previousLowerLevel(0),previousUpperLevel(0);

var : trendDirection(Nan),superTrendValue(Nan);

var : previousTrend(0);

if CurrentBar > 1 Then

{

sum = 0;

for i = 0 to rsmlen-1

{

sum = sum + c[i]*c[i];

}

source = sqrt(sum/rsmlen);

alpha = 1 / atrlen ;

atrValue1 = IFf(IsNan(atrValue1[1]) == true, ma(TrueRange,atrlen) , alpha * TrueRange + (1 - alpha) * IFf(isnan(atrValue1[1])==true,0,atrValue1[1]));

upperLevel = source + atrMult * atrValue1;

lowerLevel = source - atrMult * atrValue1;

previousLowerLevel = iff(isnan(lowerLevel[1])==true,0,lowerLevel[1]);

previousUpperLevel = iff(isnan(upperLevel[1])==true,0,upperLevel[1]);

// Ensure continuity of lower and upper bands

lowerLevel = iff(lowerLevel > previousLowerLevel or source[1] < previousLowerLevel , lowerLevel , previousLowerLevel);

upperLevel = iff(upperLevel < previousUpperLevel or source[1] > previousUpperLevel , upperLevel , previousUpperLevel);

// Determine direction and SuperTrend

previousTrend = superTrendValue[1];

// Initialize direction

if IsNan(atrValue1[1]) == true Then

trendDirection = 1;

else if previousTrend == previousUpperLevel Then

trendDirection = iff(source > upperLevel , -1 , 1);

else

trendDirection = iff(source < lowerLevel , 1 , -1);

// Set SuperTrend value based on direction

superTrendValue = iff(trendDirection == -1 , lowerLevel , upperLevel);

}

var : dist(0),chg(0),lvlCol(0);

var : tp1(0),tp2(0),tp3(0),tp4(0),tp5(0),tp6(0),tp7(0);

var : printedtp1(0),printedtp2(0),printedtp3(0),printedtp4(0),printedtp5(0),printedtp6(0),printedtp7(0);

dist = abs(close-superTrendValue);

lvlCol = iff(trendDirection > 0 , red , green);

var : key1(0);

var : key2(0);

var : key3(0);

var : key4(0);

var : key5(0);

var : key6(0);

var : key7(0);

if CrossUp(trendDirection, 0) or CrossDown(trendDirection, 0) Then

{

//TL_Delete(keys);

printedtp1 = 0;

printedtp2 = 0;

printedtp3 = 0;

printedtp4 = 0;

printedtp5 = 0;

printedtp6 = 0;

printedtp7 = 0;

chg = abs(superTrendValue-superTrendValue[1]);

tp1 = superTrendValue[1] + IFF(trendDirection > 0 , -chg , chg);

tp2 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 2 , chg * 2);

tp3 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 3 , chg * 3);

tp4 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 4 , chg * 4);

tp5 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 5 , chg * 5);

tp6 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 6 , chg * 6);

tp7 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 7 , chg * 7);

key1 = TL_new(sdate[1],stime[1],tp1, sDate,sTime, tp1);

TL_SetColor(Key1,lvlCol);

TL_SetSize(Key1,2);

printedtp1 = 1;

}

Else

TL_SetEnd(key1,sDate,sTime,TP1);

var : u(0),d(0),alp(0),ur(0),dr(0),rs(0),R(0),tp(False);

u = max(dist - dist[1], 0);

d = max(dist[1] - dist, 0);

alp = 1/tplen;

ur = IFf(IsNan(ur[1]) == true, ma(u,tplen) , alp * u + (1 - alp) * IFf(isnan(ur[1])==true,0,ur[1]));

dr = IFf(IsNan(dr[1]) == true, ma(d,tplen) , alp * d + (1 - alp) * IFf(isnan(dr[1])==true,0,dr[1]));

rs = ur / dr;

R = 100 - 100 / (1 + rs);

tp = CrossDown(R, 60);

var : extreme(0);

var : extreme_tp1_dist(0);

var : extreme_tp2_dist(0);

var : extreme_tp3_dist(0);

var : extreme_tp4_dist(0);

var : extreme_tp5_dist(0);

var : extreme_tp6_dist(0);

var : extreme_tp7_dist(0);

extreme = iff(trendDirection > 0 , low , high);

extreme_tp1_dist = abs(extreme - tp1);

extreme_tp2_dist = abs(extreme - tp2);

extreme_tp3_dist = abs(extreme - tp3);

extreme_tp4_dist = abs(extreme - tp4);

extreme_tp5_dist = abs(extreme - tp5);

extreme_tp6_dist = abs(extreme - tp6);

extreme_tp7_dist = abs(extreme - tp7);

var : tx(0),S2(0);


if tp and trendDirection > 0 Then

{

tx = Text_New(sDate,sTime,L,"X");

Text_SetStyle(tx,2,0);

Text_SetColor(tx,Red);

Text_SetSize(tx,20);

Text_SetBold(tx,1);

S2 = 1;

}

if tp and trendDirection < 0 Then

{

tx = Text_New(sDate,sTime,H,"X");

Text_SetStyle(tx,2,1);

Text_SetColor(tx,Green);

Text_SetSize(tx,20);

Text_SetBold(tx,1);

S2 = -1;

}

if printedtp2 == 0 and extreme_tp2_dist < extreme_tp1_dist Then

{

key2 = TL_new(sdate[1],stime[1],tp2, sDate,sTime, tp2);

TL_SetColor(Key2,lvlCol);

TL_SetSize(Key2,2);

printedtp2 = 1;

}

Else

{

if printedtp2 == 1 Then

TL_SetEnd(key2,sDate,sTime,TP2);

}

if printedtp3 == 0 and extreme_tp3_dist < extreme_tp2_dist Then

{

key3 = TL_new(sdate[1],stime[1],tp3, sDate,sTime, tp3);

TL_SetColor(Key3,lvlCol);

TL_SetSize(Key3,2);

printedtp3 = 1;

}

Else

{

if printedtp3 == 1 Then

TL_SetEnd(key3,sDate,sTime,TP3);

}

if printedtp4 == 0 and extreme_tp4_dist < extreme_tp3_dist Then

{

key4 = TL_new(sdate[1],stime[1],tp4, sDate,sTime, tp4);

TL_SetColor(Key4,lvlCol);

TL_SetSize(Key4,2);

printedtp4 = 1;

}

Else

{

if printedtp4 == 1 Then

TL_SetEnd(key4,sDate,sTime,TP4);

}

if printedtp5 == 0 and extreme_tp5_dist < extreme_tp4_dist Then

{

key5 = TL_new(sdate[1],stime[1],tp5, sDate,sTime, tp5);

TL_SetColor(Key5,lvlCol);

TL_SetSize(Key5,2);

printedtp5 = 1;

}

Else

{

if printedtp5 == 1 Then

TL_SetEnd(key5,sDate,sTime,TP5);

}

if printedtp6 == 0 and extreme_tp6_dist < extreme_tp5_dist Then

{

key6 = TL_new(sdate[1],stime[1],tp6, sDate,sTime, tp6);

TL_SetColor(Key6,lvlCol);

TL_SetSize(Key6,2);

printedtp6 = 1;

}

Else

{

if printedtp6 == 1 Then

TL_SetEnd(key6,sDate,sTime,TP6);

}

if printedtp7 == 0 and extreme_tp7_dist < extreme_tp6_dist Then

{

key7 = TL_new(sdate[1],stime[1],tp7, sDate,sTime, tp7);

TL_SetColor(Key7,lvlCol);

TL_SetSize(Key7,2);

printedtp7 = 1;

}

Else

{

if printedtp7 == 1 Then

TL_SetEnd(key7,sDate,sTime,TP7);

}



if MarketPosition <= 1 and S1+S2+S3== 3 Then

Sell();




if MarketPosition >= -1 and S1+S2+S3 == -3 Then

Buy();





2번 시스템



input : atrMult(4.5);

input : atrlen(12);

input : rsmlen(3);

input : tplen(14);

var : i(0),sum(0),source(0);

var : alpha(0),atrValue1(0),upperLevel(0),lowerLevel(0);

var : previousLowerLevel(0),previousUpperLevel(0);

var : trendDirection(Nan),superTrendValue(Nan);

var : previousTrend(0);

if CurrentBar > 1 Then

{

sum = 0;

for i = 0 to rsmlen-1

{

sum = sum + c[i]*c[i];

}

source = sqrt(sum/rsmlen);

alpha = 1 / atrlen ;

atrValue1 = IFf(IsNan(atrValue1[1]) == true, ma(TrueRange,atrlen) , alpha * TrueRange + (1 - alpha) * IFf(isnan(atrValue1[1])==true,0,atrValue1[1]));

upperLevel = source + atrMult * atrValue1;

lowerLevel = source - atrMult * atrValue1;

previousLowerLevel = iff(isnan(lowerLevel[1])==true,0,lowerLevel[1]);

previousUpperLevel = iff(isnan(upperLevel[1])==true,0,upperLevel[1]);

// Ensure continuity of lower and upper bands

lowerLevel = iff(lowerLevel > previousLowerLevel or source[1] < previousLowerLevel , lowerLevel , previousLowerLevel);

upperLevel = iff(upperLevel < previousUpperLevel or source[1] > previousUpperLevel , upperLevel , previousUpperLevel);

// Determine direction and SuperTrend

previousTrend = superTrendValue[1];

// Initialize direction

if IsNan(atrValue1[1]) == true Then

trendDirection = 1;

else if previousTrend == previousUpperLevel Then

trendDirection = iff(source > upperLevel , -1 , 1);

else

trendDirection = iff(source < lowerLevel , 1 , -1);

// Set SuperTrend value based on direction

superTrendValue = iff(trendDirection == -1 , lowerLevel , upperLevel);

}


var : dist(0),chg(0),lvlCol(0);

var : tp1(0),tp2(0),tp3(0),tp4(0),tp5(0),tp6(0),tp7(0);

var : printedtp1(0),printedtp2(0),printedtp3(0),printedtp4(0),printedtp5(0),printedtp6(0),printedtp7(0);

dist = abs(close-superTrendValue);

lvlCol = iff(trendDirection > 0 , red , green);

var : key1(0);

var : key2(0);

var : key3(0);

var : key4(0);

var : key5(0);

var : key6(0);

var : key7(0);

if CrossUp(trendDirection, 0) or CrossDown(trendDirection, 0) Then

{

//TL_Delete(keys);

printedtp1 = 0;

printedtp2 = 0;

printedtp3 = 0;

printedtp4 = 0;

printedtp5 = 0;

printedtp6 = 0;

printedtp7 = 0;

chg = abs(superTrendValue-superTrendValue[1]);

tp1 = superTrendValue[1] + IFF(trendDirection > 0 , -chg , chg);

tp2 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 2 , chg * 2);

tp3 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 3 , chg * 3);

tp4 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 4 , chg * 4);

tp5 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 5 , chg * 5);

tp6 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 6 , chg * 6);

tp7 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 7 , chg * 7);

key1 = TL_new(sdate[1],stime[1],tp1, sDate,sTime, tp1);

TL_SetColor(Key1,lvlCol);

TL_SetSize(Key1,2);

printedtp1 = 1;

}

Else

TL_SetEnd(key1,sDate,sTime,TP1);

var : u(0),d(0),alp(0),ur(0),dr(0),rs(0),R(0),tp(False);

u = max(dist - dist[1], 0);

d = max(dist[1] - dist, 0);

alp = 1/tplen;

ur = IFf(IsNan(ur[1]) == true, ma(u,tplen) , alp * u + (1 - alp) * IFf(isnan(ur[1])==true,0,ur[1]));

dr = IFf(IsNan(dr[1]) == true, ma(d,tplen) , alp * d + (1 - alp) * IFf(isnan(dr[1])==true,0,dr[1]));

rs = ur / dr;

R = 100 - 100 / (1 + rs);

tp = CrossDown(R, 60);

var : extreme(0);

var : extreme_tp1_dist(0);

var : extreme_tp2_dist(0);

var : extreme_tp3_dist(0);

var : extreme_tp4_dist(0);

var : extreme_tp5_dist(0);

var : extreme_tp6_dist(0);

var : extreme_tp7_dist(0);

extreme = iff(trendDirection > 0 , low , high);

extreme_tp1_dist = abs(extreme - tp1);

extreme_tp2_dist = abs(extreme - tp2);

extreme_tp3_dist = abs(extreme - tp3);

extreme_tp4_dist = abs(extreme - tp4);

extreme_tp5_dist = abs(extreme - tp5);

extreme_tp6_dist = abs(extreme - tp6);

extreme_tp7_dist = abs(extreme - tp7);

var : tx(0);

if tp and trendDirection > 0 Then

{

tx = Text_New(sDate,sTime,L,"X");

Text_SetStyle(tx,2,0);

Text_SetColor(tx,Red);

Text_SetSize(tx,20);

Text_SetBold(tx,1);


if MarketPosition <= 0 or (MarketPosition == 1 and MaxEntries < 10) Then

Buy("b");

}

if tp and trendDirection < 0 Then

{

tx = Text_New(sDate,sTime,H,"X");

Text_SetStyle(tx,2,1);

Text_SetColor(tx,Green);

Text_SetSize(tx,20);

Text_SetBold(tx,1);


if MarketPosition >= 0 or (MarketPosition == -1 and MaxEntries < 10) Then

Sell("s");

}

if printedtp2 == 0 and extreme_tp2_dist < extreme_tp1_dist Then

{

key2 = TL_new(sdate[1],stime[1],tp2, sDate,sTime, tp2);

TL_SetColor(Key2,lvlCol);

TL_SetSize(Key2,2);

printedtp2 = 1;

}

Else

{

if printedtp2 == 1 Then

TL_SetEnd(key2,sDate,sTime,TP2);

}

if printedtp3 == 0 and extreme_tp3_dist < extreme_tp2_dist Then

{

key3 = TL_new(sdate[1],stime[1],tp3, sDate,sTime, tp3);

TL_SetColor(Key3,lvlCol);

TL_SetSize(Key3,2);

printedtp3 = 1;

}

Else

{

if printedtp3 == 1 Then

TL_SetEnd(key3,sDate,sTime,TP3);

}

if printedtp4 == 0 and extreme_tp4_dist < extreme_tp3_dist Then

{

key4 = TL_new(sdate[1],stime[1],tp4, sDate,sTime, tp4);

TL_SetColor(Key4,lvlCol);

TL_SetSize(Key4,2);

printedtp4 = 1;

}

Else

{

if printedtp4 == 1 Then

TL_SetEnd(key4,sDate,sTime,TP4);

}

if printedtp5 == 0 and extreme_tp5_dist < extreme_tp4_dist Then

{

key5 = TL_new(sdate[1],stime[1],tp5, sDate,sTime, tp5);

TL_SetColor(Key5,lvlCol);

TL_SetSize(Key5,2);

printedtp5 = 1;

}

Else

{

if printedtp5 == 1 Then

TL_SetEnd(key5,sDate,sTime,TP5);

}

if printedtp6 == 0 and extreme_tp6_dist < extreme_tp5_dist Then

{

key6 = TL_new(sdate[1],stime[1],tp6, sDate,sTime, tp6);

TL_SetColor(Key6,lvlCol);

TL_SetSize(Key6,2);

printedtp6 = 1;

}

Else

{

if printedtp6 == 1 Then

TL_SetEnd(key6,sDate,sTime,TP6);

}

if printedtp7 == 0 and extreme_tp7_dist < extreme_tp6_dist Then

{

key7 = TL_new(sdate[1],stime[1],tp7, sDate,sTime, tp7);

TL_SetColor(Key7,lvlCol);

TL_SetSize(Key7,2);

printedtp7 = 1;

}

Else

{

if printedtp7 == 1 Then

TL_SetEnd(key7,sDate,sTime,TP7);

}


수고많으십니다

1번 2번 모두 지난번 만들어 주신 수식입니다

항상 감사드립니다

문의드릴 내용은 위 1번 시스템을 여러 조합으로 만들었지만

이걸 다시 조합할수 있는지 하는 내용 입니다

1번 시스템이 매수면 1점 매도면 -1점

2번 시스템이 매수면 1점 매도면 -1점

이렇게 점수를 합산하여

2점 이면 매수 -2점 이면 매도 0점 이면 집입됀 수량 모두 청산

이런 시스템을 부탁드립니다

감사합니다

시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2026-04-09 14:32:46

안녕하세요 예스스탁입니다. input : Period(20),dv(2); input : 하단아래(3),하단위(4),상단위(3),상단아래(4); var : BBup(0),BBmd(0),BBdn(0); var : T(0),i1(0),i2(0),i3(0),i4(0),S(0),value(0); BBup = BollBandUp(Period,dv); BBmd = ma(c,Period); BBdn = BollBandDown(Period,dv); if CrossDown(C,BBdn) Then { T = -1; i1 = 0; } if CrossUp(C,BBdn) Then { T = 1; i2 = 0; } if CrossUp(C,BBup) Then { T = 2; i3 = 0; } if CrossDown(C,BBup) Then { T = -2; i4 = 0; } if T == -1 Then i1 = i1+1; if T == 1 Then i2 = i2+1; if T == 2 Then i3 = i3+1; if T == -2 Then i4 = i4+1; if S <= 0 and T == 1 and i2 == 하단위 and i1 >= 하단아래 Then { S = 1; value = c-PriceScale*100; } if S >= 0 and T == -2 and i4 == 상단아래 and i3 >= 상단위 Then { S = -1; value = c+PriceScale*100; } var : S1(0); if S == 1 Then { if S == S[1] and L <= value Then S = 0; } S1 = 1; if S == -1 Then { if S == S[1] and H >= value Then S = 0; } S1 = -1; input : short1(6),long1(18),sig1(7); input : short2(6),long2(21),sig2(7); input : short3(6),long3(27),sig3(7); var : macdv1(0),macds1(0); var : macdv2(0),macds2(0); var : macdv3(0),macds3(0); macdv1 = macd(short1,long1); macds1 = ema(macdv1,sig1); macdv2 = macd(short2,long2); macds2 = ema(macdv2,sig2); macdv3 = macd(short3,long3); macds3 = ema(macdv3,sig3); var : S3(0); if macdv1 < 0 and CrossUp(macdv1,macds1) and macdv2 < 0 and CrossUp(macdv2,macds2) and macdv3 < 0 and CrossUp(macdv3,macds3) Then S3 = 1; if macdv1 > 0 and CrossUp(macdv1,macds1) and macdv2 > 0 and CrossUp(macdv2,macds2) and macdv3 > 0 and CrossUp(macdv3,macds3) Then S3 = -1; input : atrMult(4.5); input : atrlen(12); input : rsmlen(3); input : tplen(14); var : i(0),sum(0),source(0); var : alpha(0),atrValue1(0),upperLevel(0),lowerLevel(0); var : previousLowerLevel(0),previousUpperLevel(0); var : trendDirection(Nan),superTrendValue(Nan); var : previousTrend(0); if CurrentBar > 1 Then { sum = 0; for i = 0 to rsmlen-1 { sum = sum + c[i]*c[i]; } source = sqrt(sum/rsmlen); alpha = 1 / atrlen ; atrValue1 = IFf(IsNan(atrValue1[1]) == true, ma(TrueRange,atrlen) , alpha * TrueRange + (1 - alpha) * IFf(isnan(atrValue1[1])==true,0,atrValue1[1])); upperLevel = source + atrMult * atrValue1; lowerLevel = source - atrMult * atrValue1; previousLowerLevel = iff(isnan(lowerLevel[1])==true,0,lowerLevel[1]); previousUpperLevel = iff(isnan(upperLevel[1])==true,0,upperLevel[1]); // Ensure continuity of lower and upper bands lowerLevel = iff(lowerLevel > previousLowerLevel or source[1] < previousLowerLevel , lowerLevel , previousLowerLevel); upperLevel = iff(upperLevel < previousUpperLevel or source[1] > previousUpperLevel , upperLevel , previousUpperLevel); // Determine direction and SuperTrend previousTrend = superTrendValue[1]; // Initialize direction if IsNan(atrValue1[1]) == true Then trendDirection = 1; else if previousTrend == previousUpperLevel Then trendDirection = iff(source > upperLevel , -1 , 1); else trendDirection = iff(source < lowerLevel , 1 , -1); // Set SuperTrend value based on direction superTrendValue = iff(trendDirection == -1 , lowerLevel , upperLevel); } var : dist(0),chg(0),lvlCol(0); var : tp1(0),tp2(0),tp3(0),tp4(0),tp5(0),tp6(0),tp7(0); var : printedtp1(0),printedtp2(0),printedtp3(0),printedtp4(0),printedtp5(0),printedtp6(0),printedtp7(0); dist = abs(close-superTrendValue); lvlCol = iff(trendDirection > 0 , red , green); var : key1(0); var : key2(0); var : key3(0); var : key4(0); var : key5(0); var : key6(0); var : key7(0); if CrossUp(trendDirection, 0) or CrossDown(trendDirection, 0) Then { //TL_Delete(keys); printedtp1 = 0; printedtp2 = 0; printedtp3 = 0; printedtp4 = 0; printedtp5 = 0; printedtp6 = 0; printedtp7 = 0; chg = abs(superTrendValue-superTrendValue[1]); tp1 = superTrendValue[1] + IFF(trendDirection > 0 , -chg , chg); tp2 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 2 , chg * 2); tp3 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 3 , chg * 3); tp4 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 4 , chg * 4); tp5 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 5 , chg * 5); tp6 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 6 , chg * 6); tp7 = superTrendValue[1] + IFF(trendDirection > 0 , -chg * 7 , chg * 7); key1 = TL_new(sdate[1],stime[1],tp1, sDate,sTime, tp1); TL_SetColor(Key1,lvlCol); TL_SetSize(Key1,2); printedtp1 = 1; } Else TL_SetEnd(key1,sDate,sTime,TP1); var : u(0),d(0),alp(0),ur(0),dr(0),rs(0),R(0),tp(False); u = max(dist - dist[1], 0); d = max(dist[1] - dist, 0); alp = 1/tplen; ur = IFf(IsNan(ur[1]) == true, ma(u,tplen) , alp * u + (1 - alp) * IFf(isnan(ur[1])==true,0,ur[1])); dr = IFf(IsNan(dr[1]) == true, ma(d,tplen) , alp * d + (1 - alp) * IFf(isnan(dr[1])==true,0,dr[1])); rs = ur / dr; R = 100 - 100 / (1 + rs); tp = CrossDown(R, 60); var : extreme(0); var : extreme_tp1_dist(0); var : extreme_tp2_dist(0); var : extreme_tp3_dist(0); var : extreme_tp4_dist(0); var : extreme_tp5_dist(0); var : extreme_tp6_dist(0); var : extreme_tp7_dist(0); extreme = iff(trendDirection > 0 , low , high); extreme_tp1_dist = abs(extreme - tp1); extreme_tp2_dist = abs(extreme - tp2); extreme_tp3_dist = abs(extreme - tp3); extreme_tp4_dist = abs(extreme - tp4); extreme_tp5_dist = abs(extreme - tp5); extreme_tp6_dist = abs(extreme - tp6); extreme_tp7_dist = abs(extreme - tp7); var : tx(0),S2(0); if tp and trendDirection > 0 Then { tx = Text_New(sDate,sTime,L,"X"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Red); Text_SetSize(tx,20); Text_SetBold(tx,1); S2 = 1; } if tp and trendDirection < 0 Then { tx = Text_New(sDate,sTime,H,"X"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Green); Text_SetSize(tx,20); Text_SetBold(tx,1); S2 = -1; } if printedtp2 == 0 and extreme_tp2_dist < extreme_tp1_dist Then { key2 = TL_new(sdate[1],stime[1],tp2, sDate,sTime, tp2); TL_SetColor(Key2,lvlCol); TL_SetSize(Key2,2); printedtp2 = 1; } Else { if printedtp2 == 1 Then TL_SetEnd(key2,sDate,sTime,TP2); } if printedtp3 == 0 and extreme_tp3_dist < extreme_tp2_dist Then { key3 = TL_new(sdate[1],stime[1],tp3, sDate,sTime, tp3); TL_SetColor(Key3,lvlCol); TL_SetSize(Key3,2); printedtp3 = 1; } Else { if printedtp3 == 1 Then TL_SetEnd(key3,sDate,sTime,TP3); } if printedtp4 == 0 and extreme_tp4_dist < extreme_tp3_dist Then { key4 = TL_new(sdate[1],stime[1],tp4, sDate,sTime, tp4); TL_SetColor(Key4,lvlCol); TL_SetSize(Key4,2); printedtp4 = 1; } Else { if printedtp4 == 1 Then TL_SetEnd(key4,sDate,sTime,TP4); } if printedtp5 == 0 and extreme_tp5_dist < extreme_tp4_dist Then { key5 = TL_new(sdate[1],stime[1],tp5, sDate,sTime, tp5); TL_SetColor(Key5,lvlCol); TL_SetSize(Key5,2); printedtp5 = 1; } Else { if printedtp5 == 1 Then TL_SetEnd(key5,sDate,sTime,TP5); } if printedtp6 == 0 and extreme_tp6_dist < extreme_tp5_dist Then { key6 = TL_new(sdate[1],stime[1],tp6, sDate,sTime, tp6); TL_SetColor(Key6,lvlCol); TL_SetSize(Key6,2); printedtp6 = 1; } Else { if printedtp6 == 1 Then TL_SetEnd(key6,sDate,sTime,TP6); } if printedtp7 == 0 and extreme_tp7_dist < extreme_tp6_dist Then { key7 = TL_new(sdate[1],stime[1],tp7, sDate,sTime, tp7); TL_SetColor(Key7,lvlCol); TL_SetSize(Key7,2); printedtp7 = 1; } Else { if printedtp7 == 1 Then TL_SetEnd(key7,sDate,sTime,TP7); } if value1 >= 0 and S1+S2+S3== 3 Then value1 = -1; if value1 <= 0 and S1+S2+S3 == -3 Then value1 = 1; input : xatrMult(4.5); input : xatrlen(12); input : xrsmlen(3); input : xtplen(14); var : xi(0),xsum(0),xsource(0); var : xalpha(0),xatrValue1(0),xupperLevel(0),xlowerLevel(0); var : xpreviousLowerLevel(0),xpreviousUpperLevel(0); var : xtrendDirection(Nan),xsuperTrendValue(Nan); var : xpreviousTrend(0); if CurrentBar > 1 Then { xsum = 0; for xi = 0 to xrsmlen-1 { xsum = xsum + c[xi]*c[xi]; } xsource = sqrt(xsum/xrsmlen); xalpha = 1 / xatrlen ; xatrValue1 = IFf(IsNan(xatrValue1[1]) == true, ma(TrueRange,xatrlen) , xalpha * TrueRange + (1 - xalpha) * IFf(isnan(xatrValue1[1])==true,0,xatrValue1[1])); xupperLevel = xsource + xatrMult * xatrValue1; xlowerLevel = xsource - xatrMult * xatrValue1; xpreviousLowerLevel = iff(isnan(xlowerLevel[1])==true,0,xlowerLevel[1]); xpreviousUpperLevel = iff(isnan(xupperLevel[1])==true,0,xupperLevel[1]); // Ensure continuity of lower and upper bands xlowerLevel = iff(xlowerLevel > xpreviousLowerLevel or xsource[1] < xpreviousLowerLevel , xlowerLevel , xpreviousLowerLevel); xupperLevel = iff(xupperLevel < xpreviousUpperLevel or xsource[1] > xpreviousUpperLevel , xupperLevel , xpreviousUpperLevel); // Determine direction and SuperTrend xpreviousTrend = xsuperTrendValue[1]; // Initialize direction if IsNan(xatrValue1[1]) == true Then xtrendDirection = 1; else if xpreviousTrend == xpreviousUpperLevel Then xtrendDirection = iff(xsource > xupperLevel , -1 , 1); else xtrendDirection = iff(xsource < xlowerLevel , 1 , -1); // Set SuperTrend value based on direction xsuperTrendValue = iff(xtrendDirection == -1 , xlowerLevel , xupperLevel); } var : xdist(0),xchg(0),xlvlCol(0); var : xtp1(0),xtp2(0),xtp3(0),xtp4(0),xtp5(0),xtp6(0),xtp7(0); var : xprintedtp1(0),xprintedtp2(0),xprintedtp3(0),xprintedtp4(0),xprintedtp5(0),xprintedtp6(0),xprintedtp7(0); xdist = abs(close-xsuperTrendValue); xlvlCol = iff(xtrendDirection > 0 , red , green); var : xkey1(0); var : xkey2(0); var : xkey3(0); var : xkey4(0); var : xkey5(0); var : xkey6(0); var : xkey7(0); if CrossUp(xtrendDirection, 0) or CrossDown(xtrendDirection, 0) Then { //TL_Delete(keys); xprintedtp1 = 0; xprintedtp2 = 0; xprintedtp3 = 0; xprintedtp4 = 0; Xprintedtp5 = 0; xprintedtp6 = 0; xprintedtp7 = 0; xchg = abs(xsuperTrendValue-xsuperTrendValue[1]); xtp1 = xsuperTrendValue[1] + IFF(xtrendDirection > 0 , -xchg , xchg); xtp2 = xsuperTrendValue[1] + IFF(xtrendDirection > 0 , -xchg * 2 , xchg * 2); xtp3 = xsuperTrendValue[1] + IFF(xtrendDirection > 0 , -xchg * 3 , xchg * 3); xtp4 = xsuperTrendValue[1] + IFF(xtrendDirection > 0 , -xchg * 4 , xchg * 4); xtp5 = xsuperTrendValue[1] + IFF(xtrendDirection > 0 , -xchg * 5 , xchg * 5); xtp6 = xsuperTrendValue[1] + IFF(xtrendDirection > 0 , -xchg * 6 , xchg * 6); xtp7 = xsuperTrendValue[1] + IFF(xtrendDirection > 0 , -xchg * 7 , xchg * 7); xkey1 = TL_new(sdate[1],stime[1],xtp1, sDate,sTime, xtp1); TL_SetColor(xKey1,xlvlCol); TL_SetSize(xKey1,2); xprintedtp1 = 1; } Else TL_SetEnd(xkey1,sDate,sTime,xTP1); var : xu(0),xd(0),xalp(0),xur(0),xdr(0),xrs(0),xR(0),xtp(False); xu = max(xdist - xdist[1], 0); xd = max(xdist[1] - xdist, 0); xalp = 1/xtplen; xur = IFf(IsNan(xur[1]) == true, ma(xu,xtplen) , xalp * xu + (1 - xalp) * IFf(isnan(xur[1])==true,0,xur[1])); xdr = IFf(IsNan(xdr[1]) == true, ma(xd,xtplen) , xalp * xd + (1 - xalp) * IFf(isnan(xdr[1])==true,0,xdr[1])); xrs = xur / xdr; xR = 100 - 100 / (1 + xrs); xtp = CrossDown(xR, 60); var : xextreme(0); var : xextreme_tp1_dist(0); var : xextreme_tp2_dist(0); var : xextreme_tp3_dist(0); var : xextreme_tp4_dist(0); var : xextreme_tp5_dist(0); var : xextreme_tp6_dist(0); var : xextreme_tp7_dist(0); xextreme = iff(xtrendDirection > 0 , low , high); xextreme_tp1_dist = abs(xextreme - xtp1); xextreme_tp2_dist = abs(xextreme - xtp2); xextreme_tp3_dist = abs(xextreme - xtp3); xextreme_tp4_dist = abs(xextreme - xtp4); xextreme_tp5_dist = abs(xextreme - xtp5); xextreme_tp6_dist = abs(xextreme - xtp6); xextreme_tp7_dist = abs(xextreme - xtp7); var : xtx(0); if xtp and xtrendDirection > 0 Then { xtx = Text_New(sDate,sTime,L,"X"); Text_SetStyle(xtx,2,0); Text_SetColor(xtx,Red); Text_SetSize(xtx,20); Text_SetBold(xtx,1); Value2 = 1; } if xtp and xtrendDirection < 0 Then { xtx = Text_New(sDate,sTime,H,"X"); Text_SetStyle(xtx,2,1); Text_SetColor(xtx,Green); Text_SetSize(xtx,20); Text_SetBold(xtx,1); Value2 = -1; } if xprintedtp2 == 0 and xextreme_tp2_dist < xextreme_tp1_dist Then { xkey2 = TL_new(sdate[1],stime[1],xtp2, sDate,sTime, xtp2); TL_SetColor(xKey2,xlvlCol); TL_SetSize(xKey2,2); xprintedtp2 = 1; } Else { if xprintedtp2 == 1 Then TL_SetEnd(xkey2,sDate,sTime,xTP2); } if xprintedtp3 == 0 and xextreme_tp3_dist < xextreme_tp2_dist Then { xkey3 = TL_new(sdate[1],stime[1],xtp3, sDate,sTime,xtp3); TL_SetColor(xKey3,xlvlCol); TL_SetSize(xKey3,2); xprintedtp3 = 1; } Else { if xprintedtp3 == 1 Then TL_SetEnd(xkey3,sDate,sTime,xTP3); } if xprintedtp4 == 0 and xextreme_tp4_dist < xextreme_tp3_dist Then { xkey4 = TL_new(sdate[1],stime[1],xtp4, sDate,sTime,xtp4); TL_SetColor(xKey4,xlvlCol); TL_SetSize(xKey4,2); xprintedtp4 = 1; } Else { if xprintedtp4 == 1 Then TL_SetEnd(xkey4,sDate,sTime,xTP4); } if xprintedtp5 == 0 and xextreme_tp5_dist < xextreme_tp4_dist Then { xkey5 = TL_new(sdate[1],stime[1],xtp5, sDate,sTime, xtp5); TL_SetColor(xKey5,xlvlCol); TL_SetSize(xKey5,2); xprintedtp5 = 1; } Else { if xprintedtp5 == 1 Then TL_SetEnd(xkey5,sDate,sTime,xTP5); } if xprintedtp6 == 0 and xextreme_tp6_dist < xextreme_tp5_dist Then { xkey6 = TL_new(sdate[1],stime[1],xtp6, sDate,sTime,xtp6); TL_SetColor(xKey6,xlvlCol); TL_SetSize(xKey6,2); xprintedtp6 = 1; } Else { if xprintedtp6 == 1 Then TL_SetEnd(xkey6,sDate,sTime,xTP6); } if xprintedtp7 == 0 and xextreme_tp7_dist < xextreme_tp6_dist Then { xkey7 = TL_new(sdate[1],stime[1],xtp7, sDate,sTime, xtp7); TL_SetColor(xKey7,xlvlCol); TL_SetSize(xKey7,2); xprintedtp7 = 1; } Else { if xprintedtp7 == 1 Then TL_SetEnd(xkey7,sDate,sTime,xTP7); } Value3 = value1+Value2; if Value3 != Value3[1] Then { if Value3 == 2 Then Buy(); if Value3 <= 0 Then ExitLong(); if Value3 == -2 Then Sell(); if Value3 >= 0 Then ExitShort(); } 즐거운 하루되세요