커뮤니티

문의 드립니다.

프로필 이미지
신대륙발견
2024-07-30 11:11:30
1205
글번호 182022
답변완료
1) Plot1((DayClose(1)+DayOpen(1))/2); 위 수식이 전일종가와 시가를 가져와 평균값을 그리는 지표라고 하셨는데 그러면 위 수식처럼 한시간봉과 4시간봉도 각각 따로 만들어주세요. 2) // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // ~~ &#169; Zeiierman { //@version=5 indicator("Dynamic Price Oscillator (Zeiierman)", precision=0) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Tooltips { t1 = "Defines the lookback period for the oscillator and Bollinger Bands calculation. Increasing this value will consider a longer history, potentially smoothing out the oscillator and making the Bollinger Bands wider, leading to fewer signals. Decreasing this value will make the oscillator more sensitive to recent price changes, and the Bollinger Bands will become narrower, possibly increasing the number of signals." t2 = "Determines how much the oscillator's calculation is smoothed. A higher smoothing factor reduces noise and makes the oscillator's line smoother, which may help in identifying the dominant trend more clearly but can delay signal generation. A lower smoothing factor makes the oscillator more responsive to recent price movements, which can be beneficial for short-term trading strategies but may increase the risk of false signals." //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Inputs { length = input.int(33, "Length", minval=1,group="Dynamic Price Oscillator", inline="",tooltip=t1) smoothFactor = input.int(5, "Smoothing Factor", minval=1,group="Dynamic Price Oscillator", inline="",tooltip=t2) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Function to calculate True Range { trueRange(h, l, c) => tr1 = h - l tr2 = math.abs(h - c[1]) tr3 = math.abs(l - c[1]) math.max(tr1, tr2, tr3) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Function to calculate Bollinger Bands { bollingerBands(src, length, mult) => basis = ta.sma(src, length) dev = mult * ta.stdev(src, length) upper = basis + dev lower = basis - dev [upper, lower] //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Adjusted Price based on True Range { volAdjPrice = ta.ema(trueRange(high, low, close), length) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Price calculation { priceChange = (close - close[length]) priceDelta = (close - volAdjPrice) oscillator = ta.ema(math.avg(priceDelta, priceChange), smoothFactor) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Bollinger Bands on Oscillator { [bbHigh, bbLow] = bollingerBands(oscillator, length*5, 1) [bbHighExp, bbLowExp] = bollingerBands(oscillator, length*5, 2) mean = math.avg(bbHighExp,bbLowExp) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Plot { p1 = plot(oscillator, "Dynamic Price Oscillator", color = color.rgb(227, 161, 54)) plot(mean, "Dynamic Mean", color = color.new(#f7cb85,0)) p2 = plot(bbHigh, "Bollinger High", color = color.new(#089981, 60)) p3 = plot(bbHighExp, "Expanded Bollinger High", color = color.new(#089981, 0)) p4 = plot(bbLow, "Bollinger Low", color = color.new(#f23645, 60)) p5 = plot(bbLowExp, "Expanded Bollinger Low", color = color.new(#f23645, 0)) fill(p1, p2, oscillator > bbHigh ? color.new(#089981, 80) : na, "Oscillator Above Bollinger High") fill(p1, p3, oscillator > bbHighExp ? color.new(#089981, 80) : na, "Oscillator Above Expanded Bollinger High") fill(p1, p4, oscillator < bbLow ? color.new(#f23645, 80) : na, "Oscillator Below Bollinger Low") fill(p1, p5, oscillator < bbLowExp ? color.new(#f23645,80) : na, "Oscillator Below Expanded Bollinger Low") //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} 트레이딩뷰 지표인데 예스로 좀 바꿔주세요.
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2024-07-30 15:34:20

안녕하세요 예스스탁입니다. 1 input : ntime1(60); var : S1(0),D1(0),TM(0),TF(0),cnt(0); Array : CC[100](0),OO[100](0); if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; TF = TM%ntime1; if Bdate != Bdate[1] or (Bdate == Bdate[1] and ntime1 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and ntime1 > 1 and TM >= TM[1]+ntime1) or (Bdate == Bdate[1] and ntime1 == 1 and TM > TM[1]) Then { for cnt = 99 downto 1 { CC[cnt] = CC[cnt-1]; OO[cnt] = OO[cnt-1]; } OO[0] = O; } CC[0] = C; if CC[1] > 0 and OO[1] > 0 Then { Plot1((OO[1]+CC[1])/2); } } 2 input : ntime1(240); var : S1(0),D1(0),TM(0),TF(0),cnt(0); Array : CC[100](0),OO[100](0); if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; TF = TM%ntime1; if Bdate != Bdate[1] or (Bdate == Bdate[1] and ntime1 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and ntime1 > 1 and TM >= TM[1]+ntime1) or (Bdate == Bdate[1] and ntime1 == 1 and TM > TM[1]) Then { for cnt = 99 downto 1 { CC[cnt] = CC[cnt-1]; OO[cnt] = OO[cnt-1]; } OO[0] = O; } CC[0] = C; if CC[1] > 0 and OO[1] > 0 Then { Plot1((OO[1]+CC[1])/2); } } 3 input : length(33),smoothFactor(5); var : volAdjPrice(0),priceChange(0),priceDelta(0),oscillator(0); volAdjPrice = ema(trueRange, length); priceChange = (close - close[length]); priceDelta = (close - volAdjPrice); oscillator = ema(avg(priceDelta, priceChange), smoothFactor); var : bbhigh(0),bblow(0); var : bbhighExp(0),bblowExp(0),mean(0); bbhigh = ma(oscillator,length*5)+std(oscillator,length*5)*1; bblow = ma(oscillator,length*5)-std(oscillator,length*5)*1; bbhighexp = ma(oscillator,length*5)+std(oscillator,length*5)*2; bblowexp = ma(oscillator,length*5)-std(oscillator,length*5)*2; mean = avg(bbHighExp,bbLowExp); plot1(oscillator, "Dynamic Price Oscillator"); plot2(mean, "Dynamic Mean"); plot3(bbHigh, "Bollinger High"); plot4(bbHighExp, "Expanded Bollinger High"); plot5(bbLow, "Bollinger Low"); plot6(bbLowExp, "Expanded Bollinger Low"); 즐거운 하루되세요 > 신대륙발견 님이 쓴 글입니다. > 제목 : 문의 드립니다. > 1) Plot1((DayClose(1)+DayOpen(1))/2); 위 수식이 전일종가와 시가를 가져와 평균값을 그리는 지표라고 하셨는데 그러면 위 수식처럼 한시간봉과 4시간봉도 각각 따로 만들어주세요. 2) // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // ~~ &#169; Zeiierman { //@version=5 indicator("Dynamic Price Oscillator (Zeiierman)", precision=0) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Tooltips { t1 = "Defines the lookback period for the oscillator and Bollinger Bands calculation. Increasing this value will consider a longer history, potentially smoothing out the oscillator and making the Bollinger Bands wider, leading to fewer signals. Decreasing this value will make the oscillator more sensitive to recent price changes, and the Bollinger Bands will become narrower, possibly increasing the number of signals." t2 = "Determines how much the oscillator's calculation is smoothed. A higher smoothing factor reduces noise and makes the oscillator's line smoother, which may help in identifying the dominant trend more clearly but can delay signal generation. A lower smoothing factor makes the oscillator more responsive to recent price movements, which can be beneficial for short-term trading strategies but may increase the risk of false signals." //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Inputs { length = input.int(33, "Length", minval=1,group="Dynamic Price Oscillator", inline="",tooltip=t1) smoothFactor = input.int(5, "Smoothing Factor", minval=1,group="Dynamic Price Oscillator", inline="",tooltip=t2) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Function to calculate True Range { trueRange(h, l, c) => tr1 = h - l tr2 = math.abs(h - c[1]) tr3 = math.abs(l - c[1]) math.max(tr1, tr2, tr3) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Function to calculate Bollinger Bands { bollingerBands(src, length, mult) => basis = ta.sma(src, length) dev = mult * ta.stdev(src, length) upper = basis + dev lower = basis - dev [upper, lower] //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Adjusted Price based on True Range { volAdjPrice = ta.ema(trueRange(high, low, close), length) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Price calculation { priceChange = (close - close[length]) priceDelta = (close - volAdjPrice) oscillator = ta.ema(math.avg(priceDelta, priceChange), smoothFactor) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Bollinger Bands on Oscillator { [bbHigh, bbLow] = bollingerBands(oscillator, length*5, 1) [bbHighExp, bbLowExp] = bollingerBands(oscillator, length*5, 2) mean = math.avg(bbHighExp,bbLowExp) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Plot { p1 = plot(oscillator, "Dynamic Price Oscillator", color = color.rgb(227, 161, 54)) plot(mean, "Dynamic Mean", color = color.new(#f7cb85,0)) p2 = plot(bbHigh, "Bollinger High", color = color.new(#089981, 60)) p3 = plot(bbHighExp, "Expanded Bollinger High", color = color.new(#089981, 0)) p4 = plot(bbLow, "Bollinger Low", color = color.new(#f23645, 60)) p5 = plot(bbLowExp, "Expanded Bollinger Low", color = color.new(#f23645, 0)) fill(p1, p2, oscillator > bbHigh ? color.new(#089981, 80) : na, "Oscillator Above Bollinger High") fill(p1, p3, oscillator > bbHighExp ? color.new(#089981, 80) : na, "Oscillator Above Expanded Bollinger High") fill(p1, p4, oscillator < bbLow ? color.new(#f23645, 80) : na, "Oscillator Below Bollinger Low") fill(p1, p5, oscillator < bbLowExp ? color.new(#f23645,80) : na, "Oscillator Below Expanded Bollinger Low") //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} 트레이딩뷰 지표인데 예스로 좀 바꿔주세요.