답변완료
전환 추세선
Input : 전환(0.25),쌍바닥상(2),쌍바닥하(1);
Var:j(0),jj(0),HH(0),LL(0),hiBar(0),loBar(0),최종꼭지점(""),처리구분(""), TL1(0),TX1(0),tl9(0);
Array:고[10,4](0),저[10,4](0);
var : TX12(0),cond12(False);
var : box(0),BB(False);
var : TX11(0),cond11(False);
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;
TL1 = TL_New_Self(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
TL_SetSize(TL1,3);
TL_SetColor(TL1,RED);
Text_Delete(tx1);
TX1 = Text_New_Self(고[1,3],고[1,4],고[1,1],NumToStr(고[1,1]-저[1,1],2));
Text_SetSize(tx1,25);
Text_SetColor(Tx1,Red);
Text_SetStyle(tx1,1,1);
Text_SetBold(tx1,1);
}
Else 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(TL1,고[1,3],고[1,4],고[1,1]);
Text_SetString(TX1,NumToStr(고[1,1]-저[1,1],2));
Text_SetLocation(TX1,고[1,3],고[1,4],고[1,1]);
}
최종꼭지점 = "고점";
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;
cond12 = False;
if cond12 == False and 저[1,1] <= 저[2,1]+PriceScale*쌍바닥상 and
저[1,1] >= 저[2,1]-PriceScale*쌍바닥하 Then
{
cond12 = true;
tx12 = Text_New_Self(저[1,3],저[1,4],저[1,1]-PriceScale*2,"●");
Text_SetStyle(tx12,0,0);
Text_SetColor(tx12,Red);
Text_SetSize(tx12,20);
}
TL1 = TL_New_Self(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
TL_SetSize(TL1,3);
TL_SetColor(TL1,BLUE);
Text_Delete(tx1);
TX1 = Text_New_Self(저[1,3],저[1,4],저[1,1],NumToStr(저[1,1]-고[1,1],2));
Text_SetSize(tx1,25);
Text_SetColor(Tx1,Blue);
Text_SetStyle(tx1,1,0);
Text_SetBold(tx1,1);
bb = False;
if bb == False and 저[1,1] <= 고[1,1]-0.5 and 고[1,1] > 0 Then
{
bb= true;
box = Box_New_Self(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
Box_SetColor(box,Lime);
Box_SetFill(box,true,60);
}
}
Else 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;
TL_SetEnd(TL1,저[1,3],저[1,4],저[1,1]);
Text_SetString(TX1,NumToStr(저[1,1]-고[1,1],2));
Text_SetLocation(TX1,저[1,3],저[1,4],저[1,1]);
if bb == true Then
Box_SetEnd(box,저[1,3],저[1,4],저[1,1]);
Else
{
if bb == False and 저[1,1] <= 고[1,1]-0.5 and 고[1,1] > 0 Then
{
bb= true;
box = Box_New_Self(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
Box_SetColor(box,Lime);
Box_SetFill(box,true,60);
}
}
}
최종꼭지점 = "저점";
Plot2(저[1,1]);
NoPlot(1);
}
쌍바닥 부분에 오류가 납니다. 수정 부탁드립니다.
2023-04-10
1204
글번호 168038
지표
답변완료
부탁드려요
질문이 많아 죄송해요ㅜ
혼자 해보려고 했는데 잘 안돼요 ㅜ
아래 두 지표에서 종목검색식 수식을 알고 싶어요,,
1번 지표에서 빨간색 동그라미가 뜨는 종목
2번 지표에서 Plot1( c ) 또는 Plot2( c ) 가 뜨는 종목
부탁드려요(__)
1번
inputs: ATRLength(15), Strength(20), 폭(0.25);
input : 쌍바닥상1(2),쌍바닥상2(0),쌍바닥하1(1),쌍바닥하2(2);
input : 쌍봉상1(2),쌍봉상2(1),쌍봉하1(0),쌍봉하2(2);
var : STrend(0),ATRv(0), avgv(0), dnv(0), upv(0), trend(1), flag(0), flagh(0), ST(0),hl(0);
var : idx(0),hh(0),ll(0),EP1(0),EP2(0);
var : ema1(0),ema2(0),ema3(0),h1(0),h2(0),h3(0),h4(0),L1(0),l2(0),l3(0),l4(0);
var :tx(0),tl(0),tx1(0),tx2(0),tx11(0),tx12(0),tx3(0);
Ep1 = 2/(ATRLength+1);
Ep2 = 2/(Strength+1);
idx = idx+1;
if idx < ATRLength Then
{
hh = DayHigh;
ll = daylow;
}
Else
{
hh = Highest(High, ATRLength);
ll = Lowest(Low, ATRLength);
}
if idx < Strength Then
{
h1 = DayHigh;
l1 = daylow;
}
Else
{
h1 = Highest(High, Strength);
l1 = Lowest(Low, Strength);
}
hl = hh-ll;
if idx == 1 Then
{
ema1 = hl;
ema2 = h;
ema3 = l;
}
Else
{
ema1 = hl * EP1 + ema1 * (1-EP1);
ema2 = h * EP2 + ema2 * (1-EP2);
ema3 = l * EP2 + ema3 * (1-EP2);
}
atrv = ema1;
avgv = (ema2+ema3)/2;
upv = avgv + ATRv;
dnv = avgv - ATRv;
if idx >= 2 then
{
if c > upv[1] and c > h1[1] then trend = 1;
else if c < dnv[1] and c < l1[1] then trend = -1;
if trend < 0 and trend[1] > 0 then flag=1; else flag=0;
if trend > 0 and trend[1] < 0 then flagh = 1; else flagh = 0;
if trend > 0 and dnv < dnv[1] then dnv=dnv[1];
if trend < 0 and upv > upv[1] then upv=upv[1];
if flag == 1 then upv = avgv + ATRv;
if flagh == 1 then dnv = avgv - ATRv;
if trend == 1 then ST = dnv; else ST = upv;
STrend = trend;
}
Plot1(st,"SuperTrend",iff(strend == 1,red,blue));
if Trend != Trend[1] Then
{
if Trend == 1 Then
{
var1 = h;
var2 = var1[1];
TL = TL_New_Self(sDate,sTime,var1,sDate,sTime,99999999);
TL_SetColor(TL,Red);
TL_SetSize(TL,0.5);
tx = Text_New_Self(sDate,sTime, st-PriceScale*0,"●");
Text_SetColor(tx,Red);
Text_SetSize(tx,10);
Text_SetStyle(tx,2,2);
if Var4 > 0 and var3 <= Var4+PriceScale*쌍바닥상1 and var3 >= Var4+PriceScale*쌍바닥상2 Then
{
tx11 = Text_New_Self(sDate,sTime, st-PriceScale*0,"●");
Text_SetColor(tx11,Magenta);
Text_SetSize(tx11,10);
Text_SetStyle(tx11,2,2);
}
if Var4 > 0 and var3 <= Var4-PriceScale*쌍바닥하1 and var3 >= Var4-PriceScale*쌍바닥하2 Then
{
tx11 = Text_New_Self(sDate,sTime, st-PriceScale*0,"●");
Text_SetColor(tx11,Lime);
Text_SetSize(tx11,10);
Text_SetStyle(tx11,2,2);
}
}
Else
{
Var3 = l;
Var4 = Var3[1];
tx = Text_New_Self(sDate,sTime, st+PriceScale*0,"●");
Text_SetColor(tx,Blue);
Text_SetSize(tx,10);
Text_SetStyle(tx,2,2);
if Var2 > 0 and var1 <= Var2+PriceScale*쌍봉상1 and var1 >= Var2+PriceScale*쌍봉상2 Then
{
tx12 = Text_New_Self(sDate,sTime, st+PriceScale*0,"●");
Text_SetColor(tx12,Cyan);
Text_SetSize(tx12,10);
Text_SetStyle(tx12,2,2);
}
if Var2 > 0 and var1 <= Var2-PriceScale*쌍봉하1 and var1 >= Var2-PriceScale*쌍봉하2 Then
{
tx12 = Text_New_Self(sDate,sTime, st+PriceScale*0,"●");
Text_SetColor(tx12,Green);
Text_SetSize(tx12,10);
Text_SetStyle(tx12,2,2);
}
}
}
Else
{
if Trend == 1 Then
{
if h > var1 Then
var1 = h;
}
if Trend == -1 Then
{
if l < var3 Then
var3 = l;
}
}
if Trend != Trend[1] Then
{
if Trend == 1 Then
{
h2 = h;
h3 = h2[1];
h4 = h3[1];
if L4 > 0 and
max(L2,l3,l4) <= min(L2,l3,l4)+폭 Then
{
tx1 = Text_New_Self(sDate,sTime, st-PriceScale*0,"●");
Text_SetColor(tx1,Black);
Text_SetSize(tx1,10);
Text_SetStyle(tx1,2,2);
}
if Condition1 == true Then
Text_Delete(tx3);
}
Else #음전환
{
L2 = l;
l3 = l2[1];
l4 = l3[1];
Condition1 = False;
if L4 > 0 and max(l3,l4) <= min(L3,L4)+폭 Then
{
tx3 = Text_New_Self(sDate,sTime, st+PriceScale*2,"●");
Text_SetColor(tx3,Red);
Text_SetSize(tx3,10);
Text_SetStyle(tx3,2,2);
Condition1 = true;
}
if Condition1 == true and l2 < max(l3,l4)-폭 Then
{
Condition1 = False;
Text_Delete(tx3);
}
}
}
Else
{
if Trend == 1 Then
{
if h > h2 Then
h2 = h;
}
if Trend == -1 Then
{
if l < L2 Then
{
L2 = l;
if Condition1 == true and l2 < max(l3,l4)-폭 Then
{
Condition1 = False;
Text_Delete(tx3);
}
}
}
}
2번
input : Left(8),right(8);
Input : sto1(12), sto2(5), sto3(3);
var : StoK(0),StoD(0),cnt(0),T(0);
StoK = StochasticsK(sto1,sto2);
StoD = StochasticsD(sto1,sto2,sto3);
if SwingHigh(1,H,left,right,left+right+1) != -1 Then{
T = 1;
#고점값
var1 = H[right];
var2 = var1[1];
#고점일때 스토k값
var3 = stok[right];
var4 = var3[1];
#고점인덱스
var5 = index[right];
var6 = var5[1];
#고점사이의 최저값
if var6 > 0 then{
var7 = L[right];
for cnt = right to right+(var5-var6)
{
if L[cnt] < var7 Then
var7 = L[cnt];
}
}
}
if SwingLow(1,L,left,right,left+right+1) != -1 Then{
T = -1;
#저점값
value1 = L[right];
value2 = value1[1];
#저점일째 스토k값
value3 = stok[right];
value4 = value3[1];
#저점인덱스
value5 = index[right];
value6 = value5[1];
#저점사이의 최고값
if value6 > 0 then{
value7 = H[right];
for cnt = right to right+(value5-value6)
{
if H[cnt] > value7 Then
value7 = H[cnt];
}
}
}
if T == 1 and #최근 고점발생
var1 > var2 and var2 > 0 and #고점상승
var3 < var4 and #지표고점하락
var3 > 50 and var4 > 50 and #지표는 50위
CrossDown(c,var7) and #고점사이 최저가 하향이탈
stok < stod Then #스토는 데드상태
Plot1( c ) ;
if T == -1 and #최근 저점발생
value1 < value2 and value2 > 0 and #저점상승
value3 > value4 and #지표저점하락
value3 < 50 and value4 < 50 and #지표는 50아래
crossup(C,value7) and #저점사이 최고가 상향돌파
stok > stod Then #스토는 골드상태
Plot2( c ) ;
2023-04-10
812
글번호 168035
종목검색