커뮤니티

변환좀 해주세요

프로필 이미지
생각하는허수아비
2023-01-05 08:15:10
1123
글번호 165109
답변완료
바쁘신데 송구 합니다 . 아래의 트레이딩뷰의 지표를 예스로 변환좀 부탁 드립니다 . 가격캔들에 컬러를 넣도록 되어 있는것은 빼고 Heatmap Volume 만 보조지표로 만들도록 도움을 청합니다 . 감사합니다 . 이메일로 부탁드립니다 . cybersta11@ naver.com //@version=4 study(title="Heatmap Volume [xdecow]", shorttitle="HVol [xdecow]", max_bars_back=2000, format=format.volume) //------------------------------------------------------------------------------ // Inputs length = input(610, title="MA Length", type=input.integer, minval=2) slength = input(610, title='Std Length', type=input.integer, minval=2) cmode = input('Heatmap', 'Color Mode', options=['Heatmap', 'Up/Down']) zmode = input('Backgrounds', 'Display Heatmap Zones as', options=['None', 'Lines', 'Backgrounds', 'Both']) bcolor_enabled = input(true, 'Colored bars') osc = input(false, 'Show as oscillator') thresholdExtraHigh = input(4, title="Extra High Volume Threshold", type=input.float) thresholdHigh = input(2.5, title="High Volume Threshold", type=input.float) thresholdMedium = input(1, title="Medium Volume Threshold", type=input.float) thresholdNormal = input(-0.5, title="Normal Volume Threshold", type=input.float) //------------------------------------------------------------------------------ // Colors // heatmap colors chm1 = #ff0000 // extra high red chm2 = #ff7800 // high orange chm3 = #ffcf03 // medium yellow chm4 = #a0d6dc // normal chm5 = #1f9cac // low // heatmap colors chmthresholdExtraHigh = input(chm1, 'Heatmap Extra High') chmthresholdHigh = input(chm2, 'Heatmap High') chmthresholdMedium = input(chm3, 'Heatmap Medium') chmthresholdNormal = input(chm4, 'Heatmap Normal') chmthresholdLow = input(chm5, 'Heatmap Low') // up colors cupthresholdExtraHigh = input(#00FF00, 'Up Extra High') cupthresholdHigh = input(#30FF30, 'Up High') cupthresholdMedium = input(#60FF60, 'Up Medium') cupthresholdNormal = input(#8FFF8F, 'Up Normal') cupthresholdLow = input(#BFFFBF, 'Up Low') // down colors cdnthresholdExtraHigh = input(#FF0000, 'Down Extra High') cdnthresholdHigh = input(#FF3030, 'Down High') cdnthresholdMedium = input(#FF6060, 'Down Medium') cdnthresholdNormal = input(#FF8F8F, 'Down Normal') cdnthresholdLow = input(#FFBFBF, 'Down Low') // threshold colors cthresholdExtraHighUp = cmode == 'Heatmap' ? chmthresholdExtraHigh : cupthresholdExtraHigh cthresholdHighUp = cmode == 'Heatmap' ? chmthresholdHigh : cupthresholdHigh cthresholdMediumUp = cmode == 'Heatmap' ? chmthresholdMedium : cupthresholdMedium cthresholdNormalUp = cmode == 'Heatmap' ? chmthresholdNormal : cupthresholdNormal cthresholdLowUp = cmode == 'Heatmap' ? chmthresholdLow : cupthresholdLow cthresholdExtraHighDn = cmode == 'Heatmap' ? chmthresholdExtraHigh : cdnthresholdExtraHigh cthresholdHighDn = cmode == 'Heatmap' ? chmthresholdHigh : cdnthresholdHigh cthresholdMediumDn = cmode == 'Heatmap' ? chmthresholdMedium : cdnthresholdMedium cthresholdNormalDn = cmode == 'Heatmap' ? chmthresholdNormal : cdnthresholdNormal cthresholdLowDn = cmode == 'Heatmap' ? chmthresholdLow : cdnthresholdLow //------------------------------------------------------------------------------ // Calcs length := length > bar_index + 1 ? bar_index + 1 : length slength := slength > bar_index + 1 ? bar_index + 1 : slength pstdev(Series, Period) => mean = sum(Series, Period) / Period summation = 0.0 for i=0 to Period-1 sampleMinusMean = nz(Series[i]) - mean summation := summation + sampleMinusMean * sampleMinusMean return = sqrt(summation / Period) mean = sma(volume, length) std = pstdev(volume, slength) stdbar = (volume - mean) / std dir = close > open v = osc ? volume - mean : volume mosc = osc ? 0 : mean bcolor = stdbar > thresholdExtraHigh ? dir ? cthresholdExtraHighUp : cthresholdExtraHighDn : stdbar > thresholdHigh ? dir ? cthresholdHighUp : cthresholdHighDn : stdbar > thresholdMedium ? dir ? cthresholdMediumUp : cthresholdMediumDn : stdbar > thresholdNormal ? dir ? cthresholdNormalUp : cthresholdNormalDn : dir ? cthresholdLowUp : cthresholdLowDn // heatmap lines zshow_lines = zmode == 'Lines' or zmode == 'Both' zshow_backgrounds = zmode == 'Backgrounds' or zmode == 'Both' tst = highest(v, min(300, bar_index+1)) * 9999 ts0 = osc ? lowest(v, min(300, bar_index+1)) * 9999 : 0 ts1 = std * thresholdExtraHigh + mosc ts2 = std * thresholdHigh + mosc ts3 = std * thresholdMedium + mosc ts4 = std * thresholdNormal + mosc //------------------------------------------------------------------------------ // Plots barcolor(bcolor_enabled ? bcolor : na, editable=false) // hidden heatmap lines to fill pt = plot(zshow_backgrounds ? tst : na, color=na, display=display.none, editable=false) p0 = plot(zshow_backgrounds ? ts0 : na, color=na, display=display.none, editable=false) p1 = plot(zshow_backgrounds ? ts1 : na, color=na, display=display.none, editable=false) p2 = plot(zshow_backgrounds ? ts2 : na, color=na, display=display.none, editable=false) p3 = plot(zshow_backgrounds ? ts3 : na, color=na, display=display.none, editable=false) p4 = plot(zshow_backgrounds ? ts4 : na, color=na, display=display.none, editable=false) // heatmap fills tpf = 85 //fill(pt, p1, chm1, transp=tpf, title='Extra High heatmap zone') fill(p1, p2, chm2, transp=tpf, title='High heatmap zone') fill(p2, p3, chm3, transp=tpf, title='Medium heatmap zone') fill(p3, p4, chm4, transp=tpf, title='Normal heatmap zone') fill(p4, p0, chm5, transp=tpf, title='Low heatmap zone') // volume plot(v, color=bcolor, style=plot.style_columns, title='Volume', transp=0, editable=false) // moving average plot(osc ? na : mean, color=#000000, linewidth=2, title='Moving Average', style=plot.style_line, transp=0, display=display.none) // heatmap lines tpp = 50 plot(zshow_lines ? ts1 : na, color=chm1, title='Extra High heatmap line', transp=tpp) plot(zshow_lines ? ts2 : na, color=chm2, title='High heatmap line', transp=tpp) plot(zshow_lines ? ts3 : na, color=chm3, title='Medium heatmap line', transp=tpp) plot(zshow_lines ? ts4 : na, color=chm4, title='Normal heatmap line', transp=tpp)
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2023-01-05 15:14:33

안녕하세요 예스스탁입니다. input : length(610); input : slength(610); input : cmode("Heatmap");#"Heatmap" or "Up/Down" input : zmode("Backgrounds");#"None" or "Lines" or "Backgrounds" or "Both" input : bcolor_enabled(true); input : osc(false); input : thresholdExtraHigh(4); input : thresholdHigh(2.5); input : thresholdMedium(1); input : thresholdNormal(-0.5); var : chm1(0),chm2(0),chm3(0),chm4(0),chm5(0); var : chmthresholdExtraHigh(0),chmthresholdHigh(0),chmthresholdMedium(0),chmthresholdNormal(0),chmthresholdLow(0); var : cupthresholdExtraHigh(0),cupthresholdHigh(0),cupthresholdMedium(0),cupthresholdNormal(0),cupthresholdLow(0); var : cdnthresholdExtraHigh(0),cdnthresholdHigh(0),cdnthresholdMedium(0),cdnthresholdNormal(0),cdnthresholdLow(0); var : cthresholdExtraHighUp(0),cthresholdHighUp(0),cthresholdMediumUp(0),cthresholdNormalUp(0),cthresholdLowUp(0); var : cthresholdExtraHighDn(0),cthresholdHighDn(0),cthresholdMediumDn(0),cthresholdNormalDn(0),cthresholdLowDn(0); // heatmap colors chm1 = RGB(255, 0, 0); chm2 = RGB(255, 120, 0); chm3 = RGB(255, 207, 3); chm4 = RGB(160, 214, 220); chm5 = RGB(31, 156, 172); // heatmap colors chmthresholdExtraHigh = chm1; chmthresholdHigh = chm2; chmthresholdMedium = chm3; chmthresholdNormal = chm4; chmthresholdLow = chm5; // up colors cupthresholdExtraHigh = RGB(0, 255, 0); cupthresholdHigh = RGB(48, 255, 48); cupthresholdMedium = RGB(96, 255, 96); cupthresholdNormal = RGB(143, 255, 143); cupthresholdLow = RGB(191, 255, 191); // down colors cdnthresholdExtraHigh = RGB(255, 0, 0); cdnthresholdHigh = RGB(255, 48, 48); cdnthresholdMedium = RGB(255, 96, 96); cdnthresholdNormal = RGB(255, 143, 143); cdnthresholdLow = RGB(255, 191, 191); // threshold colors cthresholdExtraHighUp = iff(cmode == "Heatmap" , chmthresholdExtraHigh , cupthresholdExtraHigh); cthresholdHighUp = iff(cmode == "Heatmap" , chmthresholdHigh , cupthresholdHigh); cthresholdMediumUp = iff(cmode == "Heatmap" , chmthresholdMedium , cupthresholdMedium); cthresholdNormalUp = iff(cmode == "Heatmap" , chmthresholdNormal , cupthresholdNormal); cthresholdLowUp = iff(cmode == "Heatmap" , chmthresholdLow , cupthresholdLow); cthresholdExtraHighDn = iff(cmode == "Heatmap" , chmthresholdExtraHigh , cdnthresholdExtraHigh); cthresholdHighDn = iff(cmode == "Heatmap" , chmthresholdHigh , cdnthresholdHigh); cthresholdMediumDn = iff(cmode == "Heatmap" , chmthresholdMedium , cdnthresholdMedium); cthresholdNormalDn = iff(cmode == "Heatmap" , chmthresholdNormal , cdnthresholdNormal); cthresholdLowDn = iff(cmode == "Heatmap" , chmthresholdLow , cdnthresholdLow); //------------------------------------------------------------------------------ // Calcs var : length1(0),slength1(0); var : mean(0),stdv(0),stdbar(0),dir(False),vv(0),mosc(0),bcolor(0); var : zshow_lines(False),zshow_backgrounds(False); var : tst(0),ts0(0),ts1(0),ts2(0),ts3(0),ts4(0); length1 = iff(length > index + 1 , index + 1 , length); slength1 = iff(slength > index + 1 , index + 1 , slength); mean = ma(volume, length1); stdv = std(volume, slength1); stdbar = (volume - mean) / stdv; dir = close > open; vv = iff(osc , volume - mean , volume); mosc = iff(osc , 0 , mean); bcolor = iff(stdbar > thresholdExtraHigh , iff(dir , cthresholdExtraHighUp , cthresholdExtraHighDn), iff(stdbar > thresholdHigh , iff(dir , cthresholdHighUp , cthresholdHighDn), iff(stdbar > thresholdMedium , iff(dir , cthresholdMediumUp , cthresholdMediumDn), iff(stdbar > thresholdNormal , iff(dir , cthresholdNormalUp , cthresholdNormalDn), iff(dir , cthresholdLowUp , cthresholdLowDn))))); // heatmap lines zshow_lines = zmode == "Lines" or zmode == "Both"; zshow_backgrounds = zmode == "Backgrounds" or zmode == "Both"; tst = highest(vv, min(300, index+1)); ts0 = iff(osc , lowest(vv, min(300, index+1)) , 0); ts1 = stdv * thresholdExtraHigh + mosc; ts2 = stdv * thresholdHigh + mosc; ts3 = stdv * thresholdMedium + mosc; ts4 = stdv * thresholdNormal + mosc; plot1(iff(zshow_backgrounds , tst , nan)); plot2(iff(zshow_backgrounds , ts0 , nan)); plot3(iff(zshow_backgrounds , ts1 , nan)); plot4(iff(zshow_backgrounds , ts2 , nan)); plot5(iff(zshow_backgrounds , ts3 , nan)); plot6(iff(zshow_backgrounds , ts4 , nan)); plot7(vv,"v",bcolor); plot8(iff(osc , nan , mean),"Moving Average",rgb(0, 0, 0)); plot9(iff(zshow_lines , ts1 , nan), "Extra High heatmap line",chm1); plot10(iff(zshow_lines , ts2 , nan), "High heatmap line",chm2); plot11(iff(zshow_lines , ts3 , nan), "Medium heatmap line",chm3); plot12(iff(zshow_lines , ts4 , nan), "Normal heatmap line",chm4); 즐거운 하루되세요 > 생각하는허수아비 님이 쓴 글입니다. > 제목 : 변환좀 해주세요 > 바쁘신데 송구 합니다 . 아래의 트레이딩뷰의 지표를 예스로 변환좀 부탁 드립니다 . 가격캔들에 컬러를 넣도록 되어 있는것은 빼고 Heatmap Volume 만 보조지표로 만들도록 도움을 청합니다 . 감사합니다 . 이메일로 부탁드립니다 . cybersta11@ naver.com //@version=4 study(title="Heatmap Volume [xdecow]", shorttitle="HVol [xdecow]", max_bars_back=2000, format=format.volume) //------------------------------------------------------------------------------ // Inputs length = input(610, title="MA Length", type=input.integer, minval=2) slength = input(610, title='Std Length', type=input.integer, minval=2) cmode = input('Heatmap', 'Color Mode', options=['Heatmap', 'Up/Down']) zmode = input('Backgrounds', 'Display Heatmap Zones as', options=['None', 'Lines', 'Backgrounds', 'Both']) bcolor_enabled = input(true, 'Colored bars') osc = input(false, 'Show as oscillator') thresholdExtraHigh = input(4, title="Extra High Volume Threshold", type=input.float) thresholdHigh = input(2.5, title="High Volume Threshold", type=input.float) thresholdMedium = input(1, title="Medium Volume Threshold", type=input.float) thresholdNormal = input(-0.5, title="Normal Volume Threshold", type=input.float) //------------------------------------------------------------------------------ // Colors // heatmap colors chm1 = #ff0000 // extra high red chm2 = #ff7800 // high orange chm3 = #ffcf03 // medium yellow chm4 = #a0d6dc // normal chm5 = #1f9cac // low // heatmap colors chmthresholdExtraHigh = input(chm1, 'Heatmap Extra High') chmthresholdHigh = input(chm2, 'Heatmap High') chmthresholdMedium = input(chm3, 'Heatmap Medium') chmthresholdNormal = input(chm4, 'Heatmap Normal') chmthresholdLow = input(chm5, 'Heatmap Low') // up colors cupthresholdExtraHigh = input(#00FF00, 'Up Extra High') cupthresholdHigh = input(#30FF30, 'Up High') cupthresholdMedium = input(#60FF60, 'Up Medium') cupthresholdNormal = input(#8FFF8F, 'Up Normal') cupthresholdLow = input(#BFFFBF, 'Up Low') // down colors cdnthresholdExtraHigh = input(#FF0000, 'Down Extra High') cdnthresholdHigh = input(#FF3030, 'Down High') cdnthresholdMedium = input(#FF6060, 'Down Medium') cdnthresholdNormal = input(#FF8F8F, 'Down Normal') cdnthresholdLow = input(#FFBFBF, 'Down Low') // threshold colors cthresholdExtraHighUp = cmode == 'Heatmap' ? chmthresholdExtraHigh : cupthresholdExtraHigh cthresholdHighUp = cmode == 'Heatmap' ? chmthresholdHigh : cupthresholdHigh cthresholdMediumUp = cmode == 'Heatmap' ? chmthresholdMedium : cupthresholdMedium cthresholdNormalUp = cmode == 'Heatmap' ? chmthresholdNormal : cupthresholdNormal cthresholdLowUp = cmode == 'Heatmap' ? chmthresholdLow : cupthresholdLow cthresholdExtraHighDn = cmode == 'Heatmap' ? chmthresholdExtraHigh : cdnthresholdExtraHigh cthresholdHighDn = cmode == 'Heatmap' ? chmthresholdHigh : cdnthresholdHigh cthresholdMediumDn = cmode == 'Heatmap' ? chmthresholdMedium : cdnthresholdMedium cthresholdNormalDn = cmode == 'Heatmap' ? chmthresholdNormal : cdnthresholdNormal cthresholdLowDn = cmode == 'Heatmap' ? chmthresholdLow : cdnthresholdLow //------------------------------------------------------------------------------ // Calcs length := length > bar_index + 1 ? bar_index + 1 : length slength := slength > bar_index + 1 ? bar_index + 1 : slength pstdev(Series, Period) => mean = sum(Series, Period) / Period summation = 0.0 for i=0 to Period-1 sampleMinusMean = nz(Series[i]) - mean summation := summation + sampleMinusMean * sampleMinusMean return = sqrt(summation / Period) mean = sma(volume, length) std = pstdev(volume, slength) stdbar = (volume - mean) / std dir = close > open v = osc ? volume - mean : volume mosc = osc ? 0 : mean bcolor = stdbar > thresholdExtraHigh ? dir ? cthresholdExtraHighUp : cthresholdExtraHighDn : stdbar > thresholdHigh ? dir ? cthresholdHighUp : cthresholdHighDn : stdbar > thresholdMedium ? dir ? cthresholdMediumUp : cthresholdMediumDn : stdbar > thresholdNormal ? dir ? cthresholdNormalUp : cthresholdNormalDn : dir ? cthresholdLowUp : cthresholdLowDn // heatmap lines zshow_lines = zmode == 'Lines' or zmode == 'Both' zshow_backgrounds = zmode == 'Backgrounds' or zmode == 'Both' tst = highest(v, min(300, bar_index+1)) * 9999 ts0 = osc ? lowest(v, min(300, bar_index+1)) * 9999 : 0 ts1 = std * thresholdExtraHigh + mosc ts2 = std * thresholdHigh + mosc ts3 = std * thresholdMedium + mosc ts4 = std * thresholdNormal + mosc //------------------------------------------------------------------------------ // Plots barcolor(bcolor_enabled ? bcolor : na, editable=false) // hidden heatmap lines to fill pt = plot(zshow_backgrounds ? tst : na, color=na, display=display.none, editable=false) p0 = plot(zshow_backgrounds ? ts0 : na, color=na, display=display.none, editable=false) p1 = plot(zshow_backgrounds ? ts1 : na, color=na, display=display.none, editable=false) p2 = plot(zshow_backgrounds ? ts2 : na, color=na, display=display.none, editable=false) p3 = plot(zshow_backgrounds ? ts3 : na, color=na, display=display.none, editable=false) p4 = plot(zshow_backgrounds ? ts4 : na, color=na, display=display.none, editable=false) // heatmap fills tpf = 85 //fill(pt, p1, chm1, transp=tpf, title='Extra High heatmap zone') fill(p1, p2, chm2, transp=tpf, title='High heatmap zone') fill(p2, p3, chm3, transp=tpf, title='Medium heatmap zone') fill(p3, p4, chm4, transp=tpf, title='Normal heatmap zone') fill(p4, p0, chm5, transp=tpf, title='Low heatmap zone') // volume plot(v, color=bcolor, style=plot.style_columns, title='Volume', transp=0, editable=false) // moving average plot(osc ? na : mean, color=#000000, linewidth=2, title='Moving Average', style=plot.style_line, transp=0, display=display.none) // heatmap lines tpp = 50 plot(zshow_lines ? ts1 : na, color=chm1, title='Extra High heatmap line', transp=tpp) plot(zshow_lines ? ts2 : na, color=chm2, title='High heatmap line', transp=tpp) plot(zshow_lines ? ts3 : na, color=chm3, title='Medium heatmap line', transp=tpp) plot(zshow_lines ? ts4 : na, color=chm4, title='Normal heatmap line', transp=tpp)