커뮤니티

부탁드립니다.

프로필 이미지
양정희
2020-10-09 21:09:38
1038
글번호 142969
답변완료
// This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-sa/4.0/ // &copy; LuxAlgo //@version = 4 study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks", overlay = true , max_bars_back=1000) // toggleBreaks = input(true, title = "Show Breaks" ) leftBars = input(15, title = "Left Bars ") rightBars = input(12, title = "Right Bars") volumeThresh = input(20, title = "Volume Threshold") // highUsePivot = fixnan(pivothigh(leftBars, rightBars)[1]) lowUsePivot = fixnan(pivotlow(leftBars, rightBars)[1]) r1 = plot(highUsePivot, color=change(highUsePivot) ? na : #FF0000, linewidth=3, offset=-(rightBars+1), title="Resistance") s1 = plot(lowUsePivot, color=change(lowUsePivot) ? na : #233dee, linewidth=3, offset=-(rightBars+1), title="Support") //Volume % short = ema(volume, 5) long = ema(volume, 10) osc = 100 * (short - long) / long //For breaks with volume plotshape(toggleBreaks and crossunder(close,lowUsePivot) and not (open - close < high - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny) plotshape(toggleBreaks and crossover(close,highUsePivot ) and not(open - low > close - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny) //For bull / bear wicks plotshape(toggleBreaks and crossover(close,highUsePivot ) and open - low > close - open , title = "Break", text = 'Bull Wick', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny) plotshape(toggleBreaks and crossunder(close,lowUsePivot) and open - close < high - open , title = "Break", text = 'Bear Wick', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny) alertcondition(crossunder(close,lowUsePivot) and osc > volumeThresh , title = "Support Broken" , message = "Support Broken") alertcondition(crossover(close,highUsePivot) and osc > volumeThresh, title = "Resistance Broken" , message = "Resistance Broken") ======================================================================================= // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // &copy; LonesomeTheBlue //@version=4 study("Support Resistance - Aging [Example]", overlay = true) prd = input(defval = 20, title="Pivot Period", minval = 4, maxval = 50) src = input(defval = 'High/Low', title = "Source", options = ['High/Low', 'Close/Open']) backcolor = input(defval = "Black", title = "Background color", options = ["Black", "White"]) var float ph = na var float pl = na srch = src == 'High/Low' ? high : max(close, open) srcl = src == 'High/Low' ? low : min(close, open) ph := highestbars(srch, prd) == 0 ? srch : na pl := lowestbars(srcl, prd) == 0 ? srcl : na var col_array = array.new_color(128) if barstate.isfirst array.set(col_array, 0, #ffffff), array.set(col_array, 1, #fdfdfd), array.set(col_array, 2, #fbfbfb), array.set(col_array, 3, #f9f9f9), array.set(col_array, 4, #f7f7f7), array.set(col_array, 5, #f5f5f5), array.set(col_array, 6, #f3f3f3), array.set(col_array, 7, #f1f1f1), array.set(col_array, 8, #efefef), array.set(col_array, 9, #ededed), array.set(col_array, 10, #ebebeb), array.set(col_array, 11, #e9e9e9), array.set(col_array, 12, #e7e7e7), array.set(col_array, 13, #e5e5e5), array.set(col_array, 14, #e3e3e3), array.set(col_array, 15, #e1e1e1), array.set(col_array, 16, #dfdfdf), array.set(col_array, 17, #dddddd), array.set(col_array, 18, #dbdbdb), array.set(col_array, 19, #d9d9d9), array.set(col_array, 20, #d7d7d7), array.set(col_array, 21, #d5d5d5), array.set(col_array, 22, #d3d3d3), array.set(col_array, 23, #d1d1d1), array.set(col_array, 24, #cfcfcf), array.set(col_array, 25, #cdcdcd), array.set(col_array, 26, #cbcbcb), array.set(col_array, 27, #c9c9c9), array.set(col_array, 28, #c7c7c7), array.set(col_array, 29, #c5c5c5), array.set(col_array, 30, #c3c3c3), array.set(col_array, 31, #c1c1c1), array.set(col_array, 32, #bfbfbf), array.set(col_array, 33, #bdbdbd), array.set(col_array, 34, #bbbbbb), array.set(col_array, 35, #b9b9b9), array.set(col_array, 36, #b7b7b7), array.set(col_array, 37, #b5b5b5), array.set(col_array, 38, #b3b3b3), array.set(col_array, 39, #b1b1b1), array.set(col_array, 40, #afafaf), array.set(col_array, 41, #adadad), array.set(col_array, 42, #ababab), array.set(col_array, 43, #a9a9a9), array.set(col_array, 44, #a7a7a7), array.set(col_array, 45, #a5a5a5), array.set(col_array, 46, #a3a3a3), array.set(col_array, 47, #a1a1a1), array.set(col_array, 48, #9f9f9f), array.set(col_array, 49, #9d9d9d), array.set(col_array, 50, #9b9b9b), array.set(col_array, 51, #999999), array.set(col_array, 52, #979797), array.set(col_array, 53, #959595), array.set(col_array, 54, #939393), array.set(col_array, 55, #919191), array.set(col_array, 56, #8f8f8f), array.set(col_array, 57, #8d8d8d), array.set(col_array, 58, #8b8b8b), array.set(col_array, 59, #898989), array.set(col_array, 60, #878787), array.set(col_array, 61, #858585), array.set(col_array, 62, #838383), array.set(col_array, 63, #818181), array.set(col_array, 64, #7f7f7f), array.set(col_array, 65, #7d7d7d), array.set(col_array, 66, #7b7b7b), array.set(col_array, 67, #797979), array.set(col_array, 68, #777777), array.set(col_array, 69, #757575), array.set(col_array, 70, #737373), array.set(col_array, 71, #717171), array.set(col_array, 72, #6f6f6f), array.set(col_array, 73, #6d6d6d), array.set(col_array, 74, #6b6b6b), array.set(col_array, 75, #696969), array.set(col_array, 76, #676767), array.set(col_array, 77, #656565), array.set(col_array, 78, #636363), array.set(col_array, 79, #616161), array.set(col_array, 80, #5f5f5f), array.set(col_array, 81, #5d5d5d), array.set(col_array, 82, #5b5b5b), array.set(col_array, 83, #595959), array.set(col_array, 84, #575757), array.set(col_array, 85, #555555), array.set(col_array, 86, #535353), array.set(col_array, 87, #515151), array.set(col_array, 88, #4f4f4f), array.set(col_array, 89, #4d4d4d), array.set(col_array, 90, #4b4b4b), array.set(col_array, 91, #494949), array.set(col_array, 92, #474747), array.set(col_array, 93, #454545), array.set(col_array, 94, #434343), array.set(col_array, 95, #414141), array.set(col_array, 96, #3f3f3f), array.set(col_array, 97, #3d3d3d), array.set(col_array, 98, #3b3b3b), array.set(col_array, 99, #393939), array.set(col_array, 100, #373737), array.set(col_array, 101, #353535), array.set(col_array, 102, #333333), array.set(col_array, 103, #313131), array.set(col_array, 104, #2f2f2f), array.set(col_array, 105, #2d2d2d), array.set(col_array, 106, #2b2b2b), array.set(col_array, 107, #292929), array.set(col_array, 108, #272727), array.set(col_array, 109, #252525), array.set(col_array, 110, #232323), array.set(col_array, 111, #212121), array.set(col_array, 112, #1f1f1f), array.set(col_array, 113, #1d1d1d), array.set(col_array, 114, #1b1b1b), array.set(col_array, 115, #191919), array.set(col_array, 116, #171717), array.set(col_array, 117, #151515), array.set(col_array, 118, #131313), array.set(col_array, 119, #111111), array.set(col_array, 120, #0f0f0f), array.set(col_array, 121, #0d0d0d), array.set(col_array, 122, #0b0b0b), array.set(col_array, 123, #090909), array.set(col_array, 124, #070707), array.set(col_array, 125, #050505), array.set(col_array, 126, #030303), array.set(col_array, 127, #010101), max_array_size = 10 // 5 R or S level, 1 age, 1 level = 5 * (1 + 1) = 10 var r_levels = array.new_float(0) var s_levels = array.new_float(0) // add new S/R age and level to the array add_array(srarray, level)=> if array.size(srarray) >= max_array_size array.pop(srarray) array.pop(srarray) array.unshift(srarray, level) // S/Rlevel array.unshift(srarray, 0) // age // aging function get_older(srarray)=> if array.size(srarray) > 0 for i = 0 to array.size(srarray) - 1 by 2 array.set(srarray, i, array.get(srarray, i) + 1) if array.get(srarray, array.size(srarray) - 2) > 127 array.pop(srarray) array.pop(srarray) remove_element_from_r_if_broken()=> notremoved = true if array.size(r_levels) > 0 for i = 1 to array.size(r_levels) - 1 by 2 if close > array.get(r_levels, i) array.remove(r_levels, i) array.remove(r_levels, i - 1) notremoved := false break notremoved remove_element_from_s_if_broken()=> notremoved = true if array.size(s_levels) > 0 for i = 1 to array.size(s_levels) - 1 by 2 if close < array.get(s_levels, i) array.remove(s_levels, i) array.remove(s_levels, i - 1) notremoved := false break notremoved if ph or pl add_array(ph ? r_levels : s_levels, (ph ? ph : pl)) // aging get_older(r_levels) get_older(s_levels) // remove broken S/R levels if array.size(r_levels) > 0 for i = 1 to array.size(r_levels) if remove_element_from_r_if_broken() break if array.size(s_levels) > 0 for i = 1 to array.size(s_levels) if remove_element_from_s_if_broken() break get_level(srarray, i)=> float level = na if array.size(srarray) > i if array.get(srarray, i - 1) > 1 // if age > 1 level := array.get(srarray, i) level get_color(srarray, i)=> color retcol = na if array.size(srarray) > i if array.get(srarray, i) > 1 and array.get(srarray, i) < 128 if backcolor == "Black" retcol := array.get(col_array, round(array.get(srarray, i))) else retcol := array.get(col_array, 127 - round(array.get(srarray, i))) retcol plot(get_level(r_levels, 1), color =get_color(r_levels, 0), style = plot.style_circles) plot(get_level(r_levels, 3), color =get_color(r_levels, 2), style = plot.style_circles) plot(get_level(r_levels, 5), color =get_color(r_levels, 4), style = plot.style_circles) plot(get_level(r_levels, 7), color =get_color(r_levels, 6), style = plot.style_circles) plot(get_level(r_levels, 9), color =get_color(r_levels, 8), style = plot.style_circles) plot(get_level(s_levels, 1), color =get_color(s_levels, 0), style = plot.style_circles) plot(get_level(s_levels, 3), color =get_color(s_levels, 2), style = plot.style_circles) plot(get_level(s_levels, 5), color =get_color(s_levels, 4), style = plot.style_circles) plot(get_level(s_levels, 7), color =get_color(s_levels, 6), style = plot.style_circles) plot(get_level(s_levels, 9), color =get_color(s_levels, 8), style = plot.style_circles) sr_text = "Resistance Levels / Age" if array.size(r_levels) > 1 for x = 1 to array.size(r_levels) - 1 by 2 if array.get(r_levels, x - 1) > 1 sr_text := sr_text + " " + tostring(array.get(r_levels, x)) + " / " + tostring(array.get(r_levels, x - 1)) sr_text := sr_text + " " + "Support Levels / Age" if array.size(s_levels) > 1 for x = 1 to array.size(s_levels) - 1 by 2 if array.get(s_levels, x - 1) > 1 sr_text := sr_text + " " + tostring(array.get(s_levels, x)) + " / " + tostring(array.get(s_levels, x - 1)) ptime = time - time[1] var label srlabel = na label.delete(srlabel) srlabel := label.new(time + 20 * ptime, close, text = sr_text, xloc = xloc.bar_time, color = color.yellow, textcolor = color.black) ====================================================================================== //@version=4 //Basic Hull Ma Pack tinkered by InSilico - Modified by Crystoba Sept 2020 study("CS Hull Suite", shorttitle="CS Hull Suite" , overlay=true) //INPUT src = input(close, title="Source") modeSwitch = input("Hma", title="Hull Variation", options=["Hma", "Thma", "Ehma"]) showFhull = input(title="Show fast Hull?", type=input.bool, defval=true, confirm=false) fastlength = input(55, title="Def: 55 for swing entry)") showShull = input(title="Show slow Hull?", type=input.bool, defval=true, confirm=false) slowlength = input(180, title="Def: 180-200 for floating S/R") switchColor = input(true, "Color Hull according to trend?") candleCol = input(false,title="Color candles based on Hull's Trend?") visualSwitch = input(true, title="Show as a Band?") thicknesSwitch = input(1, title="Line Thickness") transpSwitch = input(40, title="Band Transparency",step=5) //FUNCTIONS //HMA FHMA(_src, _fastlength) => wma(2 * wma(_src, _fastlength / 2) - wma(_src, _fastlength), round(sqrt(_fastlength))) SHMA(_src, _slowlength) => wma(2 * wma(_src, _slowlength / 2) - wma(_src, _slowlength), round(sqrt(_slowlength))) //EHMA FEHMA(_src, _fastlength) => ema(2 * ema(_src, _fastlength / 2) - ema(_src, _fastlength), round(sqrt(_fastlength))) SEHMA(_src, _slowlength) => ema(2 * ema(_src, _slowlength / 2) - ema(_src, _slowlength), round(sqrt(_slowlength))) //THMA FTHMA(_src, _fastlength) => wma(wma(_src,_fastlength / 3) * 3 - wma(_src, _fastlength / 2) - wma(_src, _fastlength), _fastlength) STHMA(_src, _slowlength) => wma(wma(_src,_slowlength / 3) * 3 - wma(_src, _slowlength / 2) - wma(_src, _slowlength), _slowlength) //SWITCH FMode(modeSwitch, src, len) => modeSwitch == "Hma" ? FHMA(src, len) : modeSwitch == "Ehma" ? FEHMA(src, len) : modeSwitch == "Thma" ? FTHMA(src, len/2) : na SMode(modeSwitch, src, len) => modeSwitch == "Hma" ? SHMA(src, len) : modeSwitch == "Ehma" ? SEHMA(src, len) : modeSwitch == "Thma" ? STHMA(src, len/2) : na //OUT - FAST FHULL = FMode(modeSwitch, src, fastlength) FMHULL = FHULL[0] FSHULL = FHULL[2] //OUT - SLOW SHULL = SMode(modeSwitch, src, slowlength) SMHULL = SHULL[0] SSHULL = SHULL[2] //COLOR FhullColor = switchColor ? (FHULL > FHULL[2] ? #00ff00 : #ff0000) : #ff9800 ShullColor = switchColor ? (SHULL > SHULL[2] ? #ffeb3b : #9c27b0) : #ff9800 //PLOT ///< Frame FFi1 = plot(showFhull ? FMHULL : na, title="FMHULL", color=FhullColor, linewidth=thicknesSwitch, transp=50) FFi2 = plot(visualSwitch ? showFhull ? FSHULL : na : na, title="FHULL", color=FhullColor, linewidth=thicknesSwitch, transp=50) SFi1 = plot(showShull ? SMHULL : na, title="SMHULL", color=ShullColor, linewidth=thicknesSwitch, transp=50) SFi2 = plot(visualSwitch ? showShull ? SSHULL : na : na, title="SHULL", color=ShullColor, linewidth=thicknesSwitch, transp=50) ///< Ending Filler fill(FFi1, FFi2, title="Fast Band Filler", color=FhullColor, transp=transpSwitch) fill(SFi1, SFi2, title="Slow Band Filler", color=ShullColor, transp=transpSwitch) ///BARCOLOR barcolor(color = candleCol ? (switchColor ? ShullColor : na) : na) ------------------------------------------------------------------------------------ 트레이딩뷰소스 변환 부탁드려요. 너무 자주 부탁드리게 되네요. 항상 감사드립니다.
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2020-10-12 15:24:05

안녕하세요 예스스탁입니다. 1 input : toggleBreaks(true),leftBars(15),rightBars(12),volumeThresh(20); var : SH(0),SL(0),highUsePivot(0),lowUsePivot(0),tx1(0),tx2(0); if SwingHigh(1,h,leftBars,rightBars,leftBars+rightBars+1) != -1 Then SH = H[rightBars]; highUsePivot = SH[1]; if SwingLow(1,l,leftBars,rightBars,leftBars+rightBars+1) != -1 Then SL = L[rightBars]; lowUsePivot = SL[1]; if highUsePivot > 0 Then plot1(highUsePivot,"Resistance",RED); if lowUsePivot > 0 Then plot2(lowUsePivot, "Support",BLUE); var : short(0),long(0),osc(0); short = ema(volume, 5); long = ema(volume, 10); osc = 100 * (short - long) / long; if toggleBreaks and CrossDown(close,lowUsePivot) and !(open - close < high - open) and osc > volumeThresh Then { tx1 = Text_New(sDate,sTime,L,"Break"); Text_SetStyle(tx1,2,0); } if toggleBreaks and CrossUp(close,highUsePivot ) and !(open - low > close - open) and osc > volumeThresh Then { tx1 = Text_New(sDate,sTime,H,"Break"); Text_SetStyle(tx1,2,1); } //For bull / bear wicks if toggleBreaks and CrossUp(close,highUsePivot ) and open - low > close - open Then { tx2 = Text_New(sDate,sTime,H,"Bull Wick"); Text_SetStyle(tx2,2,1); } if toggleBreaks and CrossDown(close,lowUsePivot) and open - close < high - open Then { tx2 = Text_New(sDate,sTime,L,"Bear Wick"); Text_SetStyle(tx2,2,0); } 2 2번 수식은 기능을 알수 없는 함수들이 많아 변환을 해드릴수 없습니다. 도움을 드리지 못해 죄송합니다. 3 input : modeSwitch("Hma"),showFhull(true),fastlength(55),showShull(true),slowlength(180), switchColor(true),candleCol(false),visualSwitch(true),thicknesSwitch(1),transpSwitch(40); var : src(0),FHULL(0),SHULL(0),FMHULL(0),FSHULL(0),SMHULL(0),SSHULL(0),FhullColor(0),ShullColor(0); src = c; if modeSwitch == "Hma" Then { FHULL = wma(2 * wma(src, fastlength / 2) - wma(src, fastlength), round(sqrt(fastlength),0)); SHULL = wma(2 * wma(src, slowlength / 2) - wma(src, slowlength), round(sqrt(slowlength),0)); } if modeSwitch == "Ehma" Then { FHULL = ema(2 * ema(src, fastlength / 2) - ema(src, fastlength), round(sqrt(fastlength),0)); SHULL = ema(2 * ema(src, fastlength / 2) - ema(src, fastlength), round(sqrt(fastlength),0)); } if modeSwitch == "Thma" Then { FHULL = wma(wma(src,fastlength / 3) * 3 - wma(src, fastlength / 2) - wma(src, fastlength), fastlength); SHULL = wma(wma(src,fastlength / 3) * 3 - wma(src, fastlength / 2) - wma(src, fastlength), fastlength); } //OUT - FAST FMHULL = FHULL[0]; FSHULL = FHULL[2]; //OUT - SLOW SMHULL = SHULL[0]; SSHULL = SHULL[2]; //COLOR FhullColor = IFf(switchColor , iff(FHULL > FHULL[2],RED,MAGENTA),GREEN); ShullColor = iff(switchColor , IFf(SHULL > SHULL[2],BLUe,CYAN),GRAY); plot1(iff(showFhull,FMHULL,Nan),"FMHULL",FhullColor); plot2(iff(visualSwitch ,IFf(showFhull, FSHULL ,Nan),Nan),"FHULL",FhullColor); plot3(iff(showShull,SMHULL,Nan),"SMHULL",ShullColor); plot4(iff(visualSwitch , IFf(showShull,SSHULL,Nan),Nan),"SHULL",ShullColor); 즐거운 하루되세요 > 양정희 님이 쓴 글입니다. > 제목 : 부탁드립니다. > // This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-sa/4.0/ // &#169; LuxAlgo //@version = 4 study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks", overlay = true , max_bars_back=1000) // toggleBreaks = input(true, title = "Show Breaks" ) leftBars = input(15, title = "Left Bars ") rightBars = input(12, title = "Right Bars") volumeThresh = input(20, title = "Volume Threshold") // highUsePivot = fixnan(pivothigh(leftBars, rightBars)[1]) lowUsePivot = fixnan(pivotlow(leftBars, rightBars)[1]) r1 = plot(highUsePivot, color=change(highUsePivot) ? na : #FF0000, linewidth=3, offset=-(rightBars+1), title="Resistance") s1 = plot(lowUsePivot, color=change(lowUsePivot) ? na : #233dee, linewidth=3, offset=-(rightBars+1), title="Support") //Volume % short = ema(volume, 5) long = ema(volume, 10) osc = 100 * (short - long) / long //For breaks with volume plotshape(toggleBreaks and crossunder(close,lowUsePivot) and not (open - close < high - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny) plotshape(toggleBreaks and crossover(close,highUsePivot ) and not(open - low > close - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny) //For bull / bear wicks plotshape(toggleBreaks and crossover(close,highUsePivot ) and open - low > close - open , title = "Break", text = 'Bull Wick', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny) plotshape(toggleBreaks and crossunder(close,lowUsePivot) and open - close < high - open , title = "Break", text = 'Bear Wick', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny) alertcondition(crossunder(close,lowUsePivot) and osc > volumeThresh , title = "Support Broken" , message = "Support Broken") alertcondition(crossover(close,highUsePivot) and osc > volumeThresh, title = "Resistance Broken" , message = "Resistance Broken") ======================================================================================= // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // &#169; LonesomeTheBlue //@version=4 study("Support Resistance - Aging [Example]", overlay = true) prd = input(defval = 20, title="Pivot Period", minval = 4, maxval = 50) src = input(defval = 'High/Low', title = "Source", options = ['High/Low', 'Close/Open']) backcolor = input(defval = "Black", title = "Background color", options = ["Black", "White"]) var float ph = na var float pl = na srch = src == 'High/Low' ? high : max(close, open) srcl = src == 'High/Low' ? low : min(close, open) ph := highestbars(srch, prd) == 0 ? srch : na pl := lowestbars(srcl, prd) == 0 ? srcl : na var col_array = array.new_color(128) if barstate.isfirst array.set(col_array, 0, #ffffff), array.set(col_array, 1, #fdfdfd), array.set(col_array, 2, #fbfbfb), array.set(col_array, 3, #f9f9f9), array.set(col_array, 4, #f7f7f7), array.set(col_array, 5, #f5f5f5), array.set(col_array, 6, #f3f3f3), array.set(col_array, 7, #f1f1f1), array.set(col_array, 8, #efefef), array.set(col_array, 9, #ededed), array.set(col_array, 10, #ebebeb), array.set(col_array, 11, #e9e9e9), array.set(col_array, 12, #e7e7e7), array.set(col_array, 13, #e5e5e5), array.set(col_array, 14, #e3e3e3), array.set(col_array, 15, #e1e1e1), array.set(col_array, 16, #dfdfdf), array.set(col_array, 17, #dddddd), array.set(col_array, 18, #dbdbdb), array.set(col_array, 19, #d9d9d9), array.set(col_array, 20, #d7d7d7), array.set(col_array, 21, #d5d5d5), array.set(col_array, 22, #d3d3d3), array.set(col_array, 23, #d1d1d1), array.set(col_array, 24, #cfcfcf), array.set(col_array, 25, #cdcdcd), array.set(col_array, 26, #cbcbcb), array.set(col_array, 27, #c9c9c9), array.set(col_array, 28, #c7c7c7), array.set(col_array, 29, #c5c5c5), array.set(col_array, 30, #c3c3c3), array.set(col_array, 31, #c1c1c1), array.set(col_array, 32, #bfbfbf), array.set(col_array, 33, #bdbdbd), array.set(col_array, 34, #bbbbbb), array.set(col_array, 35, #b9b9b9), array.set(col_array, 36, #b7b7b7), array.set(col_array, 37, #b5b5b5), array.set(col_array, 38, #b3b3b3), array.set(col_array, 39, #b1b1b1), array.set(col_array, 40, #afafaf), array.set(col_array, 41, #adadad), array.set(col_array, 42, #ababab), array.set(col_array, 43, #a9a9a9), array.set(col_array, 44, #a7a7a7), array.set(col_array, 45, #a5a5a5), array.set(col_array, 46, #a3a3a3), array.set(col_array, 47, #a1a1a1), array.set(col_array, 48, #9f9f9f), array.set(col_array, 49, #9d9d9d), array.set(col_array, 50, #9b9b9b), array.set(col_array, 51, #999999), array.set(col_array, 52, #979797), array.set(col_array, 53, #959595), array.set(col_array, 54, #939393), array.set(col_array, 55, #919191), array.set(col_array, 56, #8f8f8f), array.set(col_array, 57, #8d8d8d), array.set(col_array, 58, #8b8b8b), array.set(col_array, 59, #898989), array.set(col_array, 60, #878787), array.set(col_array, 61, #858585), array.set(col_array, 62, #838383), array.set(col_array, 63, #818181), array.set(col_array, 64, #7f7f7f), array.set(col_array, 65, #7d7d7d), array.set(col_array, 66, #7b7b7b), array.set(col_array, 67, #797979), array.set(col_array, 68, #777777), array.set(col_array, 69, #757575), array.set(col_array, 70, #737373), array.set(col_array, 71, #717171), array.set(col_array, 72, #6f6f6f), array.set(col_array, 73, #6d6d6d), array.set(col_array, 74, #6b6b6b), array.set(col_array, 75, #696969), array.set(col_array, 76, #676767), array.set(col_array, 77, #656565), array.set(col_array, 78, #636363), array.set(col_array, 79, #616161), array.set(col_array, 80, #5f5f5f), array.set(col_array, 81, #5d5d5d), array.set(col_array, 82, #5b5b5b), array.set(col_array, 83, #595959), array.set(col_array, 84, #575757), array.set(col_array, 85, #555555), array.set(col_array, 86, #535353), array.set(col_array, 87, #515151), array.set(col_array, 88, #4f4f4f), array.set(col_array, 89, #4d4d4d), array.set(col_array, 90, #4b4b4b), array.set(col_array, 91, #494949), array.set(col_array, 92, #474747), array.set(col_array, 93, #454545), array.set(col_array, 94, #434343), array.set(col_array, 95, #414141), array.set(col_array, 96, #3f3f3f), array.set(col_array, 97, #3d3d3d), array.set(col_array, 98, #3b3b3b), array.set(col_array, 99, #393939), array.set(col_array, 100, #373737), array.set(col_array, 101, #353535), array.set(col_array, 102, #333333), array.set(col_array, 103, #313131), array.set(col_array, 104, #2f2f2f), array.set(col_array, 105, #2d2d2d), array.set(col_array, 106, #2b2b2b), array.set(col_array, 107, #292929), array.set(col_array, 108, #272727), array.set(col_array, 109, #252525), array.set(col_array, 110, #232323), array.set(col_array, 111, #212121), array.set(col_array, 112, #1f1f1f), array.set(col_array, 113, #1d1d1d), array.set(col_array, 114, #1b1b1b), array.set(col_array, 115, #191919), array.set(col_array, 116, #171717), array.set(col_array, 117, #151515), array.set(col_array, 118, #131313), array.set(col_array, 119, #111111), array.set(col_array, 120, #0f0f0f), array.set(col_array, 121, #0d0d0d), array.set(col_array, 122, #0b0b0b), array.set(col_array, 123, #090909), array.set(col_array, 124, #070707), array.set(col_array, 125, #050505), array.set(col_array, 126, #030303), array.set(col_array, 127, #010101), max_array_size = 10 // 5 R or S level, 1 age, 1 level = 5 * (1 + 1) = 10 var r_levels = array.new_float(0) var s_levels = array.new_float(0) // add new S/R age and level to the array add_array(srarray, level)=> if array.size(srarray) >= max_array_size array.pop(srarray) array.pop(srarray) array.unshift(srarray, level) // S/Rlevel array.unshift(srarray, 0) // age // aging function get_older(srarray)=> if array.size(srarray) > 0 for i = 0 to array.size(srarray) - 1 by 2 array.set(srarray, i, array.get(srarray, i) + 1) if array.get(srarray, array.size(srarray) - 2) > 127 array.pop(srarray) array.pop(srarray) remove_element_from_r_if_broken()=> notremoved = true if array.size(r_levels) > 0 for i = 1 to array.size(r_levels) - 1 by 2 if close > array.get(r_levels, i) array.remove(r_levels, i) array.remove(r_levels, i - 1) notremoved := false break notremoved remove_element_from_s_if_broken()=> notremoved = true if array.size(s_levels) > 0 for i = 1 to array.size(s_levels) - 1 by 2 if close < array.get(s_levels, i) array.remove(s_levels, i) array.remove(s_levels, i - 1) notremoved := false break notremoved if ph or pl add_array(ph ? r_levels : s_levels, (ph ? ph : pl)) // aging get_older(r_levels) get_older(s_levels) // remove broken S/R levels if array.size(r_levels) > 0 for i = 1 to array.size(r_levels) if remove_element_from_r_if_broken() break if array.size(s_levels) > 0 for i = 1 to array.size(s_levels) if remove_element_from_s_if_broken() break get_level(srarray, i)=> float level = na if array.size(srarray) > i if array.get(srarray, i - 1) > 1 // if age > 1 level := array.get(srarray, i) level get_color(srarray, i)=> color retcol = na if array.size(srarray) > i if array.get(srarray, i) > 1 and array.get(srarray, i) < 128 if backcolor == "Black" retcol := array.get(col_array, round(array.get(srarray, i))) else retcol := array.get(col_array, 127 - round(array.get(srarray, i))) retcol plot(get_level(r_levels, 1), color =get_color(r_levels, 0), style = plot.style_circles) plot(get_level(r_levels, 3), color =get_color(r_levels, 2), style = plot.style_circles) plot(get_level(r_levels, 5), color =get_color(r_levels, 4), style = plot.style_circles) plot(get_level(r_levels, 7), color =get_color(r_levels, 6), style = plot.style_circles) plot(get_level(r_levels, 9), color =get_color(r_levels, 8), style = plot.style_circles) plot(get_level(s_levels, 1), color =get_color(s_levels, 0), style = plot.style_circles) plot(get_level(s_levels, 3), color =get_color(s_levels, 2), style = plot.style_circles) plot(get_level(s_levels, 5), color =get_color(s_levels, 4), style = plot.style_circles) plot(get_level(s_levels, 7), color =get_color(s_levels, 6), style = plot.style_circles) plot(get_level(s_levels, 9), color =get_color(s_levels, 8), style = plot.style_circles) sr_text = "Resistance Levels / Age" if array.size(r_levels) > 1 for x = 1 to array.size(r_levels) - 1 by 2 if array.get(r_levels, x - 1) > 1 sr_text := sr_text + " " + tostring(array.get(r_levels, x)) + " / " + tostring(array.get(r_levels, x - 1)) sr_text := sr_text + " " + "Support Levels / Age" if array.size(s_levels) > 1 for x = 1 to array.size(s_levels) - 1 by 2 if array.get(s_levels, x - 1) > 1 sr_text := sr_text + " " + tostring(array.get(s_levels, x)) + " / " + tostring(array.get(s_levels, x - 1)) ptime = time - time[1] var label srlabel = na label.delete(srlabel) srlabel := label.new(time + 20 * ptime, close, text = sr_text, xloc = xloc.bar_time, color = color.yellow, textcolor = color.black) ====================================================================================== //@version=4 //Basic Hull Ma Pack tinkered by InSilico - Modified by Crystoba Sept 2020 study("CS Hull Suite", shorttitle="CS Hull Suite" , overlay=true) //INPUT src = input(close, title="Source") modeSwitch = input("Hma", title="Hull Variation", options=["Hma", "Thma", "Ehma"]) showFhull = input(title="Show fast Hull?", type=input.bool, defval=true, confirm=false) fastlength = input(55, title="Def: 55 for swing entry)") showShull = input(title="Show slow Hull?", type=input.bool, defval=true, confirm=false) slowlength = input(180, title="Def: 180-200 for floating S/R") switchColor = input(true, "Color Hull according to trend?") candleCol = input(false,title="Color candles based on Hull's Trend?") visualSwitch = input(true, title="Show as a Band?") thicknesSwitch = input(1, title="Line Thickness") transpSwitch = input(40, title="Band Transparency",step=5) //FUNCTIONS //HMA FHMA(_src, _fastlength) => wma(2 * wma(_src, _fastlength / 2) - wma(_src, _fastlength), round(sqrt(_fastlength))) SHMA(_src, _slowlength) => wma(2 * wma(_src, _slowlength / 2) - wma(_src, _slowlength), round(sqrt(_slowlength))) //EHMA FEHMA(_src, _fastlength) => ema(2 * ema(_src, _fastlength / 2) - ema(_src, _fastlength), round(sqrt(_fastlength))) SEHMA(_src, _slowlength) => ema(2 * ema(_src, _slowlength / 2) - ema(_src, _slowlength), round(sqrt(_slowlength))) //THMA FTHMA(_src, _fastlength) => wma(wma(_src,_fastlength / 3) * 3 - wma(_src, _fastlength / 2) - wma(_src, _fastlength), _fastlength) STHMA(_src, _slowlength) => wma(wma(_src,_slowlength / 3) * 3 - wma(_src, _slowlength / 2) - wma(_src, _slowlength), _slowlength) //SWITCH FMode(modeSwitch, src, len) => modeSwitch == "Hma" ? FHMA(src, len) : modeSwitch == "Ehma" ? FEHMA(src, len) : modeSwitch == "Thma" ? FTHMA(src, len/2) : na SMode(modeSwitch, src, len) => modeSwitch == "Hma" ? SHMA(src, len) : modeSwitch == "Ehma" ? SEHMA(src, len) : modeSwitch == "Thma" ? STHMA(src, len/2) : na //OUT - FAST FHULL = FMode(modeSwitch, src, fastlength) FMHULL = FHULL[0] FSHULL = FHULL[2] //OUT - SLOW SHULL = SMode(modeSwitch, src, slowlength) SMHULL = SHULL[0] SSHULL = SHULL[2] //COLOR FhullColor = switchColor ? (FHULL > FHULL[2] ? #00ff00 : #ff0000) : #ff9800 ShullColor = switchColor ? (SHULL > SHULL[2] ? #ffeb3b : #9c27b0) : #ff9800 //PLOT ///< Frame FFi1 = plot(showFhull ? FMHULL : na, title="FMHULL", color=FhullColor, linewidth=thicknesSwitch, transp=50) FFi2 = plot(visualSwitch ? showFhull ? FSHULL : na : na, title="FHULL", color=FhullColor, linewidth=thicknesSwitch, transp=50) SFi1 = plot(showShull ? SMHULL : na, title="SMHULL", color=ShullColor, linewidth=thicknesSwitch, transp=50) SFi2 = plot(visualSwitch ? showShull ? SSHULL : na : na, title="SHULL", color=ShullColor, linewidth=thicknesSwitch, transp=50) ///< Ending Filler fill(FFi1, FFi2, title="Fast Band Filler", color=FhullColor, transp=transpSwitch) fill(SFi1, SFi2, title="Slow Band Filler", color=ShullColor, transp=transpSwitch) ///BARCOLOR barcolor(color = candleCol ? (switchColor ? ShullColor : na) : na) ------------------------------------------------------------------------------------ 트레이딩뷰소스 변환 부탁드려요. 너무 자주 부탁드리게 되네요. 항상 감사드립니다.