답변완료
수식문의입니다
키움증권과 예스의 이평선 산정 방식이 틀리나요?
라인형태가 틀리게 나와서 문의드립니다.
원인이 뭔지 알려주세요
1.키움수식
A5=avg(C,5,지수);
A10=avg(C,10,지수);
A20=avg(C,20,지수);
B=ValueWhen(1,A5<A10 && A10<A20 && A5<A20, C);
D=ValueWhen(1,B(2)>B(1) && B(1)<B,B(1));
ValueWhen(1,CrossUp(B,D),B)
2.예스수식
mav1 = ema(C,5);
mav2 = ema(C,10);
mav3 = ema(C,20);
//5,10,20지수이평선이 완전 역배열시에는 종가(C) 저장
if mav1 < mav2 && mav2 < mav3 && mav1 < mav3 Then
DPT = C;
if DPT[2] > DPT[1] && DPT[1] < DPT Then
DPY = DPT[1];
if CrossUp(mav1,DPY) Then
역배열지지C = mav1;
plot1(역배열지지C,"역배열지지C돌파이평선");
>>>>> 키움의 ValueWhen(1,CrossUp(B,D),B)선과 예스의 plot1선이 다르게 표시되는 이유가 뭘까요?
2025-08-22
117
글번호 193433
지표
답변완료
문의 드립니다.
// --- settings
ATRperiod = input.int(defval=13, title='ATR Period', minval=1)
BBperiod = input.int(defval=6, title='Bollinger Bands Period', minval=1)
BBdeviation = input.float(defval=5.00, title='Bollinger Bands Deviation', minval=0.1, step=0.1)
UseATRfilter = input(defval=true, title='ATR Filter On/Off') // false = 0, true = 1
showsignals = input(title='Show Signals ', defval=true)
// --- end of settings
// Bollinger Bands calculation
BBUpper = ta.sma(close, BBperiod) + ta.stdev(close, BBperiod) * BBdeviation
BBLower = ta.sma(close, BBperiod) - ta.stdev(close, BBperiod) * BBdeviation
// ATR calculation
atrValue = ta.atr(ATRperiod)
// Signal initialization
var float FollowLine = na
var int BBSignal = 0
// Determine BB signal
if (close > BBUpper)
BBSignal := 1
else if (close < BBLower)
BBSignal := -1
// Buy signal logic
if (BBSignal == 1)
if (UseATRfilter)
FollowLine := low - atrValue
else
FollowLine := low
if (FollowLine < nz(FollowLine[1]))
FollowLine := nz(FollowLine[1])
// Sell signal logic
if (BBSignal == -1)
if (UseATRfilter)
FollowLine := high + atrValue
else
FollowLine := high
if (FollowLine > nz(FollowLine[1]))
FollowLine := nz(FollowLine[1])
// Trend direction determination
var int iTrend = 0
if (nz(FollowLine) > nz(FollowLine[1]))
iTrend := 1
else if (nz(FollowLine) < nz(FollowLine[1]))
iTrend := -1
// Trend line color based on trend direction
lineColor = iTrend > 0 ? color.rgb(9, 98, 232) : color.new(color.rgb(220, 20, 60), 0)
//buy & sell conditions
buy=0.0
sell=0.0
buy:=iTrend[1]==-1 and iTrend==1 ? 1 : na
sell:=iTrend[1]==1 and iTrend==-1? 1 : na
//alerts
alertcondition(sell == 1 ,title="Sell",message="Follow Line Sell")
alertcondition(buy == 1 ,title="Buy",message="Follow Line Buy")
alertcondition(buy == 1 or sell == 1 ,title="Signal",message="Follow Line Signal")
// Plot the trend line and signals
plot(FollowLine, color=lineColor, linewidth=2, title="Follow Line")
plotshape(buy == 1 and showsignals ? FollowLine-atrValue :na, text='BUY', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto)
plotshape(sell == 1 and showsignals ? FollowLine+atrValue:na, text='SELL', style=shape.labeldown, location=location.absolute, color=color.rgb(102, 15, 15), textcolor=color.white, offset=0, transp=0,size=size.auto)
트레이딩뷰 수식입니다.
위 수식을 예스 지표로 만들어주시고
신호검색 수식도 만들어주세요.