커뮤니티

두수식 결합

프로필 이미지
고성
2026-06-01 06:21:25
103
글번호 232231
답변완료

매수만 있는 1수식과 매도만 있는 2수식을 단순 결합했는데 ,오류가 납니다.

수정 부탁드립니다.


Input : shortPeriod(100), longPeriod(200), Period(60);

Var : MACDv(0), MACDsig(0),HH(0),LL(0),T(0),TL(0);

MACDv = MACD(shortPeriod, longPeriod);

MACDsig = ma(MACDv,Period);

if macdv > macdsig [1] Then

T = 1;

HH = H;

if macdv < macdsig [1] Then

T = -1;

LL = L;

if T == 1 and T != T[1] and MACDsig <= -0.5 Then

{

TL = TL_New(sDate,sTime,L+1,sDate,sTime,1999);

TL_SetColor(TL,Red);

Buy();

}

if MarketPosition == 1 and BarsSinceEntry == 1 Then ExitLong();




input : Period2(150);

Var:j(0);

Var: date11(0),date12(0),time11(0),time12(0);

Array:HiVal[20](0),LoVal[20](0),HiBar[20](0),LoBar[20](0);

For j = 0 To 19

{

HiBar[j] = HiBar[j] + 1;

LoBar[j] = LoBar[j] + 1;

}

if crossup(c,highest(H,Period2)[1]) Then

T = 1;

if CrossDown(c,Lowest(L,Period2)[1]) Then

T = -1;

If T == -1 Then

{

If T[1] != -1 Then

{

For j = 18 DownTo 0

{

LoVal[j+1] = LoVal[j];

LoBar[j+1] = LoBar[j];

}

LoVal[0] = L;

LoBar[0] = 0;

date11 = date[HiBar[0]];

time11 = stime[HiBar[0]];

Value11 = HiVal[0];

date12 = date[LoBar[0]];

time12 = stime[LoBar[0]];

Value12 = LoVal[0];

Condition1 = False;

Condition2 = False;

}

If LoVal[0] > L Then

{

LoVal[0] = L;

LoBar[0] = 0;

date12 = date[LoBar[0]];

time12 = stime[LoBar[0]];

Value12 = LoVal[0];

if Condition1 == False and Value12 <= value11-10 Then

{

Condition1 = true;

Sell();

}

if Condition2 == False and Value12 <= value11-15 Then

{

Condition2 = true;

Sell();

}

}

}

If T == 1 Then

{

If T[1] != 1 Then

{

For j = 18 DownTo 0

{

HiVal[j+1] = HiVal[j];

HiBar[j+1] = HiBar[j];

}

HiVal[0] = H;

HiBar[0] = 0;

date11 = date[LoBar[0]];

time11 = stime[LoBar[0]];

Value11 = LoVal[0];

date12 = date[HiBar[0]];

time12 = stime[HiBar[0]];

Value12 = HiVal[0];

Condition5 = False;

Condition6 = False;

}

If HiVal[0] < H Then

{

HiVal[0] = H;

HiBar[0] = 0;

date12 = date[HiBar[0]];

time12 = stime[HiBar[0]];

Value12 = HiVal[0];

if Condition5 == False and Value12 >= value11+10 Then

{

Condition5 = true;

Sell();

}

if Condition6 == False and Value12 >= value11+15 Then

{

Condition6 = true;

Sell();

}

}

}

if MarketPosition == -1 and BarsSinceEntry == 1 Then ExitShort();


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

예스스탁 예스스탁 답변

2026-06-01 13:56:03

안녕하세요 예스스탁입니다. 2개의 수식에 같은 이름의 변수가 있으면 하나는 다른 이름으로 변경하셔야 합니다. Input : shortPeriod(100), longPeriod(200), Period(60); Var : MACDv(0), MACDsig(0),HH(0),LL(0),T(0),TL(0); MACDv = MACD(shortPeriod, longPeriod); MACDsig = ma(MACDv,Period); if macdv > macdsig [1] Then T = 1; HH = H; if macdv < macdsig [1] Then T = -1; LL = L; if T == 1 and T != T[1] and MACDsig <= -0.5 Then { TL = TL_New(sDate,sTime,L+1,sDate,sTime,1999); TL_SetColor(TL,Red); Buy(); } if MarketPosition == 1 and BarsSinceEntry == 1 Then ExitLong(); input : Period2(150); Var:j(0),S(0); Var: date11(0),date12(0),time11(0),time12(0); Array:HiVal[20](0),LoVal[20](0),HiBar[20](0),LoBar[20](0); For j = 0 To 19 { HiBar[j] = HiBar[j] + 1; LoBar[j] = LoBar[j] + 1; } if crossup(c,highest(H,Period2)[1]) Then S = 1; if CrossDown(c,Lowest(L,Period2)[1]) Then S = -1; If S == -1 Then { If S[1] != -1 Then { For j = 18 DownTo 0 { LoVal[j+1] = LoVal[j]; LoBar[j+1] = LoBar[j]; } LoVal[0] = L; LoBar[0] = 0; date11 = date[HiBar[0]]; time11 = stime[HiBar[0]]; Value11 = HiVal[0]; date12 = date[LoBar[0]]; time12 = stime[LoBar[0]]; Value12 = LoVal[0]; Condition1 = False; Condition2 = False; } If LoVal[0] > L Then { LoVal[0] = L; LoBar[0] = 0; date12 = date[LoBar[0]]; time12 = stime[LoBar[0]]; Value12 = LoVal[0]; if Condition1 == False and Value12 <= value11-10 Then { Condition1 = true; Sell(); } if Condition2 == False and Value12 <= value11-15 Then { Condition2 = true; Sell(); } } } If S == 1 Then { If S[1] != 1 Then { For j = 18 DownTo 0 { HiVal[j+1] = HiVal[j]; HiBar[j+1] = HiBar[j]; } HiVal[0] = H; HiBar[0] = 0; date11 = date[LoBar[0]]; time11 = stime[LoBar[0]]; Value11 = LoVal[0]; date12 = date[HiBar[0]]; time12 = stime[HiBar[0]]; Value12 = HiVal[0]; Condition5 = False; Condition6 = False; } If HiVal[0] < H Then { HiVal[0] = H; HiBar[0] = 0; date12 = date[HiBar[0]]; time12 = stime[HiBar[0]]; Value12 = HiVal[0]; if Condition5 == False and Value12 >= value11+10 Then { Condition5 = true; Sell(); } if Condition6 == False and Value12 >= value11+15 Then { Condition6 = true; Sell(); } } } if MarketPosition == -1 and BarsSinceEntry == 1 Then ExitShort(); 즐거운 하루되세요