답변완료
전환추세 상하대칭
Input : 전환(0.4);
Var:j(0),jj(0),HH(0),LL(0),hiBar(0),loBar(0),최종꼭지점(""),처리구분(""), TL(0),TX(0);
Array:고[10,4](0),저[10,4](0);
var : btx1(0),btx2(0),btx3(0),btx11(0),btx12(0),btx13(0),btx14(0),btx21(0),btx22(0),btx23(0),btx24(0);
HH = H;
LL = L;
If Index == 0 Then
{
고[1,1] = HH;
고[1,2] = 0;
고[1,3] = sDate;
고[1,4] = sTime;
저[1,1] = LL;
저[1,2] = 0;
저[1,3] = sDate;
저[1,4] = sTime;
}
If Index > 0 Then
{
hiBar = hiBar + 1;
loBar = loBar + 1;
}
If HH[hiBar] < HH Then hiBar = 0;
If LL[loBar] > LL Then loBar = 0;
Condition1 = 저[1,1]+전환 <= HH and hiBar == 0;
Condition2 = 고[1,1]-전환 >= LL and loBar == 0;
처리구분 = "";
If Condition1 and Condition2 Then
{
If 최종꼭지점 == "저점" Then
{
If 저[1,1] > LL Then 처리구분 = "저점처리";
Else 처리구분 = "고점처리";
}
Else If 최종꼭지점 == "고점" Then
{
If 고[1,1] < HH Then 처리구분 = "고점처리";
Else 처리구분 = "저점처리";
}
}
Else If Condition1 Then 처리구분 = "고점처리";
Else If Condition2 Then 처리구분 = "저점처리";
If 처리구분 == "고점처리" Then
{
If 최종꼭지점 == "저점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 4
{
고[j,jj] = 고[j-1,jj];
}
}
고[1,1] = HH[hiBar];
고[1,2] = Index - hiBar;
고[1,3] = sDate[hiBar];
고[1,4] = sTime[hiBar];
hiBar = -1;
loBar = -1;
TL = TL_New(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
TL_SetSize(TL,2);
TL_SetColor(TL,Red);
Condition2 = False;
}
if 고[1,1] > 0 and 저[1,1] > 0 and Condition2 == False and 고[1,1] >= 저[1,1]+0.95 Then
{
Condition2 = true;
btx11 = Text_New(저[1,3],저[1,4],저[1,1]+abs(고[1,1]-저[1,1])*1.618,"■");
btx12 = Text_New(저[1,3],저[1,4],저[1,1]+abs(고[1,1]-저[1,1])*0.618,"■");
btx13 = Text_New(저[1,3],저[1,4],저[1,1]+abs(고[1,1]-저[1,1])*2,"■");
btx1 = Text_New(저[1,3],저[1,4],저[1,1]+abs(고[1,1]-저[1,1]),"■");
btx2 = Text_New(저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1]),"■");
btx21 = Text_New(저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1])*1.618,"■");
btx22 = Text_New(저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1])*0.618,"■");
btx23 = Text_New(저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1])*0.5,"■");
btx24 = Text_New(저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1])*2,"■");
Text_SetStyle(btx11,2,2);
Text_SetStyle(btx12,2,2);
Text_SetStyle(btx1,2,2);
Text_SetStyle(btx2,2,2);
Text_SetStyle(btx21,2,2);
Text_SetStyle(btx22,2,2);
Text_SetStyle(btx23,2,2);
Text_SetStyle(btx13,2,2);
Text_SetStyle(btx24,2,2);
Text_SetColor(btx11,Lime);
Text_SetColor(btx12,Lime);
Text_SetColor(btx1,Red);
Text_SetColor(btx2,Red);
Text_SetColor(btx21,Lime);
Text_SetColor(btx22,Lime);
Text_SetColor(btx23,Green);
Text_SetColor(btx13,Red);
Text_SetColor(btx24,Red);
}
If 고[1,1] < HH[hiBar] Then
{
고[1,1] = HH[hiBar];
고[1,2] = Index - hiBar;
고[1,3] = sDate[hiBar];
고[1,4] = sTime[hiBar];
hiBar = -1;
loBar = -1;
TL_SetEnd(TL,고[1,3],고[1,4],고[1,1]);
if Condition2 == true Then
{
Text_SetLocation(btx11, 저[1,3],저[1,4],저[1,1]+abs(고[1,1]-저[1,1])*1.618);
Text_SetLocation(btx12, 저[1,3],저[1,4],저[1,1]+abs(고[1,1]-저[1,1])*0.618);
Text_SetLocation(btx13, 저[1,3],저[1,4],저[1,1]+abs(고[1,1]-저[1,1])*2);
Text_SetLocation(btx1, 저[1,3],저[1,4],저[1,1]+abs(고[1,1]-저[1,1]));
Text_SetLocation(btx2, 저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1]));
Text_SetLocation(btx21, 저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1])*1.618);
Text_SetLocation(btx22, 저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1])*0.618);
Text_SetLocation(btx23, 저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1])*0.5);
Text_SetLocation(btx24, 저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1])*2);
}
}
최종꼭지점 = "고점";
Plot1(고[1,1]);
NoPlot(2);
}
If 처리구분 == "저점처리" Then
{
If 최종꼭지점 == "고점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 4
{
저[j,jj] = 저[j-1,jj];
}
}
저[1,1] = LL[loBar];
저[1,2] = Index - loBar;
저[1,3] = sDate[loBar];
저[1,4] = sTime[loBar];
hiBar = -1;
loBar = -1;
TL = TL_New(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
TL_SetSize(TL,2);
TL_SetColor(TL,Blue);
Condition1 = False;
}
if 고[1,1] > 0 and 저[1,1] > 0 and Condition1 == False and 저[1,1] <= 고[1,1]-0.95 Then
{
Condition1 = true;
btx11 = Text_New(저[1,3],저[1,4],고[1,1]+abs(고[1,1]-저[1,1])*1.618,"■");
btx12 = Text_New(저[1,3],저[1,4],고[1,1]+abs(고[1,1]-저[1,1])*0.618,"■");
btx13 = Text_New(저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1])*0.5,"■");
btx14 = Text_New(저[1,3],저[1,4],고[1,1]+abs(고[1,1]-저[1,1])*2,"■");
btx1 = Text_New(저[1,3],저[1,4],고[1,1]+abs(고[1,1]-저[1,1]),"■");
btx2 = Text_New(저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1]),"■");
btx21 = Text_New(저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1])*1.618,"■");
btx22 = Text_New(저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1])*0.618,"■");
btx24 = Text_New(저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1])*2,"■");
Text_SetStyle(btx11,2,2);
Text_SetStyle(btx12,2,2);
Text_SetStyle(btx13,2,2);
Text_SetStyle(btx14,2,2);
Text_SetStyle(btx1,2,2);
Text_SetStyle(btx2,2,2);
Text_SetStyle(btx21,2,2);
Text_SetStyle(btx22,2,2);
Text_SetStyle(btx24,2,2);
Text_SetColor(btx11,Lime);
Text_SetColor(btx12,Lime);
Text_SetColor(btx13,Green);
Text_SetColor(btx1,Blue);
Text_SetColor(btx2,Blue);
Text_SetColor(btx21,Lime);
Text_SetColor(btx22,Lime);
Text_SetColor(btx14,Blue);
Text_SetColor(btx24,Blue);
}
If 저[1,1] > LL[loBar] Then
{
저[1,1] = LL[loBar];
저[1,2] = Index - loBar;
저[1,3] = sDate[loBar];
저[1,4] = sTime[loBar];
hiBar = -1;
loBar = -1;
if Condition1 == true Then
{
Text_SetLocation(btx11, 저[1,3],저[1,4],고[1,1]+abs(고[1,1]-저[1,1])*1.618);
Text_SetLocation(btx12, 저[1,3],저[1,4],고[1,1]+abs(고[1,1]-저[1,1])*0.618);
Text_SetLocation(btx13, 저[1,3],저[1,4],고[1,1]-abs(고[1,1]-저[1,1])*0.5);
Text_SetLocation(btx14, 저[1,3],저[1,4],고[1,1]+abs(고[1,1]-저[1,1])*2);
Text_SetLocation(btx1, 저[1,3],저[1,4],고[1,1]+abs(고[1,1]-저[1,1]));
Text_SetLocation(btx2, 저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1]));
Text_SetLocation(btx21, 저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1])*1.618);
Text_SetLocation(btx22, 저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1])*0.618);
Text_SetLocation(btx24, 저[1,3],저[1,4],저[1,1]-abs(고[1,1]-저[1,1])*2);
}
TL_SetEnd(TL,저[1,3],저[1,4],저[1,1]);
}
최종꼭지점 = "저점";
Plot2(저[1,1]);
NoPlot(1);
}
추세선이 0.95p 이상 커지면(작으면 무시), 그 크기의 0.618배, 배, 1.618배, 2배 지점을, 추세선 상하단으로부터 위아래에 표시. 수정 부탁드립니다.
2023-08-13
1271
글번호 171444
지표