답변완료
키움증권 수식 변환을 부탁드립니다.
수고하십니다. 키움 수식 변환을 부탁드립니다.
새해 복많이 받으십시요
S=sum(1);
TT=S%기간;
조건=TT==1;
HH=HighestSince(1,조건,H);
Hc=valuewhen(1,조건,HH(1));
LL=LowestSince(1,조건,L);
Lc=valuewhen(1,조건,LL(1));
Cc=valuewhen(1,조건,C(1));
Oo=valuewhen(2,조건,O);
기준=Hc+Lc+Cc;
고=if(Cc>Oo, (기준+Hc)/2-Lc,
if(Cc<Oo, (기준+Lc)/2-Lc, (기준+Cc)/2-Lc));
저=if(Cc>Oo, (기준+Hc)/2-Hc,
if(Cc<Oo, (기준+Lc)/2-Hc, (기준+Cc)/2-Hc));
(고+저)/2
-----------------
기간 : 3
비율 : 3
2022-12-29
1337
글번호 164964
지표
답변완료
트렌드 쓰리바닥
inputs: ATRLength(15), Strength(18), 폭(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,20);
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,30);
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,30);
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,20);
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,30);
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,30);
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,20);
Text_SetStyle(tx1,2,2);
}
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,40);
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);
}
}
}
}
첨부한 파일에서 아래쪽이 수정한 실시간 쓰리바닥인데 표시한 부분에 동그라미 출력이 안됩니다. 161줄의 Text_Delete(tx3); 와 연관된 듯 합니다. 실시간 쓰리바닥은 잘됩니다.
여러번 귀찮게 하네요. 고맙습니다.
2022-12-28
1104
글번호 164949
지표