커뮤니티

예스랭귀지 Q&A

글쓰기
답변완료

부탁 드립니다.

다바스 박스의 20기간중 상단 3프로 근처에 있는 종목 수식과 20일 상단 돌파 종목 검색식을 어떻게 만들어야 할지 수식좀 부탁드립니다.
프로필 이미지
한천
2021-04-27
992
글번호 148446
종목검색
답변완료

부탁 드립니다.

변환 드립니다. 미리 감사 드립니다. if(ull>c,floor(ull*rf),ceil(ull*rf))/rf;
프로필 이미지
yes
2021-04-27
827
글번호 148445
지표
답변완료

수정 부탁 드립니다.

피보나치 되돌림선 전캔들 까지만 표시 되는데 우측 끝까지 추세선 연장 부탁 드립니다. Input:length(5); input : Per1(0),Per2(23.6),Per3(38.2),Per4(50.0),Per5(61.8),Per6(76.4),Per7(100); Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0),Text1(0),처리구분(""),T(0),mav(0),diff(0); var: TL2(0),TL3(0),TL4(0),TL5(0),TL6(0),TL7(0),TL8(0); var: TL12(0),TL13(0),TL14(0),TL15(0),TL16(0),TL17(0),TL18(0); Array:고점[10,2](0),저점[10,2](0); 처리구분 = ""; If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then { If 저점[1,1] > L Then 처리구분 = "저점처리"; If 고점[1,1] < H Then 처리구분 = "고점처리"; } Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리"; Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리"; If 처리구분 == "고점처리" Then { T = 1; lastHiVal = H; If 고점[1,2] < 저점[1,2] Then { For j = 10 DownTo 2 { 고점[j,1] = 고점[j-1,1]; 고점[j,2] = 고점[j-1,2]; } } If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then { 고점[1,1] = H; 고점[1,2] = Index; sBar = Index - 저점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); TL_Delete(TL2); TL_Delete(TL3); TL_Delete(TL4); TL_Delete(TL5); TL_Delete(TL6); TL_Delete(TL7); TL_Delete(TL8); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1],sDate[eBar],sTime[eBar],고점[1,1]); TL_SetColor(TL1,YELLOW); #TL_SetSize(TL1,1); var1 = 고점[2,1]; var2 = 저점[1,1]; var3 = abs(var1-var2); TL2 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per1/100),sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per1/100)); TL3 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per2/100),sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per2/100)); TL4 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per3/100),sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per3/100)); TL5 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per4/100),sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per4/100)); TL6 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per5/100),sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per5/100)); TL7 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per6/100),sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per6/100)); TL8 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per7/100),sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per7/100)); TL_SetColor(TL2,BLUE); TL_SetColor(TL3,BLUE); TL_SetColor(TL4,BLUE); TL_SetColor(TL5,BLUE); TL_SetColor(TL6,BLUE); TL_SetColor(TL7,BLUE); TL_SetColor(TL8,BLUE); Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1]+PriceScale*3,NumToStr((고점[1,1]*10)%1000,0)+" +"+NumToStr(abs(고점[1,1]-저점[1,1])/PriceScale,0)); Text_SetStyle(Text1, 2, 1); Text_SetColor(Text1,RED); If 고점[3,1] < 고점[2,1] and 고점[2,1] > 고점[1,1] and 저점[2,1] < 저점[1,1] Then { sBar = Index - 저점[2,2]; eBar = Index - 저점[1,2]; } } } If 처리구분 == "저점처리" Then { T = -1; lastLoVal = L; If 저점[1,2] < 고점[1,2] Then { For j = 10 DownTo 2 { 저점[j,1] = 저점[j-1,1]; 저점[j,2] = 저점[j-1,2]; } } If 저점[1,2] < 고점[1,2] or 저점[1,1] > L Then { 저점[1,1] = L; 저점[1,2] = Index; sBar = Index - 고점[1,2]; eBar = 0; If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then { TL_Delete(TL1); TL_Delete(TL2); TL_Delete(TL3); TL_Delete(TL4); TL_Delete(TL5); TL_Delete(TL6); TL_Delete(TL7); TL_Delete(TL8); Text_Delete(Text1); } TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1],sDate[eBar],sTime[eBar],저점[1,1]); #TL_SetSize(TL1,1); TL_SetColor(TL1,YELLOW); var1 = 고점[1,1]; var2 = 저점[2,1]; var3 = abs(var1-var2); TL2 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per1/100),sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per1/100)); TL3 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per2/100),sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per2/100)); TL4 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per3/100),sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per3/100)); TL5 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per4/100),sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per4/100)); TL6 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per5/100),sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per5/100)); TL7 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per6/100),sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per6/100)); TL8 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var1-var3*(Per7/100),sdate[index-고점[1,2]],stime[index-고점[1,2]],var1-var3*(Per7/100)); TL_SetColor(TL2,red); TL_SetColor(TL3,red); TL_SetColor(TL4,red); TL_SetColor(TL5,red); TL_SetColor(TL6,red); TL_SetColor(TL7,red); TL_SetColor(TL8,red); Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1]-PriceScale*3,NumToStr((저점[1,1]*10)%1000,0)+" -"+NumToStr(abs(저점[1,1]-고점[1,1])/PriceScale,0)); Text_SetStyle(Text1, 2, 0); Text_SetColor(Text1,BLUE); If 저점[2,1] < 저점[1,1] and 저점[2,1] < 저점[3,1] and 고점[2,1] > 고점[1,1] Then { sBar = Index - 고점[2,2]; eBar = Index - 고점[1,2]; } } } mav = ma(C,20); if T == 1 Then{ TL_Delete(TL12); TL_Delete(TL13); TL_Delete(TL14); TL_Delete(TL15); TL_Delete(TL16); TL_Delete(TL17); TL_Delete(TL18); var11 = 고점[1,1]; var12 = 저점[1,1]; var13 = abs(var11-var12); TL12 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var11-var13*(Per1/100),sdate,stime,var11-var13*(Per1/100)); TL13 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var11-var13*(Per2/100),sdate,stime,var11-var13*(Per2/100)); TL14 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var11-var13*(Per3/100),sdate,stime,var11-var13*(Per3/100)); TL15 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var11-var13*(Per4/100),sdate,stime,var11-var13*(Per4/100)); TL16 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var11-var13*(Per5/100),sdate,stime,var11-var13*(Per5/100)); TL17 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var11-var13*(Per6/100),sdate,stime,var11-var13*(Per6/100)); TL18 = TL_New(sdate[index-고점[1,2]],stime[index-고점[1,2]],var11-var13*(Per7/100),sdate,stime,var11-var13*(Per7/100)); TL_SetColor(TL12,red); TL_SetColor(TL13,red); TL_SetColor(TL14,red); TL_SetColor(TL15,red); TL_SetColor(TL16,red); TL_SetColor(TL17,red); TL_SetColor(TL18,red); } if T == -1 Then{ TL_Delete(TL12); TL_Delete(TL13); TL_Delete(TL14); TL_Delete(TL15); TL_Delete(TL16); TL_Delete(TL17); TL_Delete(TL18); var11 = 고점[1,1]; var12 = 저점[1,1]; var13 = abs(var11-var12); TL12 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var11-var13*(Per1/100),sdate,stime,var11-var13*(Per1/100)); TL13 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var11-var13*(Per2/100),sdate,stime,var11-var13*(Per2/100)); TL14 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var11-var13*(Per3/100),sdate,stime,var11-var13*(Per3/100)); TL15 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var11-var13*(Per4/100),sdate,stime,var11-var13*(Per4/100)); TL16 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var11-var13*(Per5/100),sdate,stime,var11-var13*(Per5/100)); TL17 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var11-var13*(Per6/100),sdate,stime,var11-var13*(Per6/100)); TL18 = TL_New(sdate[index-저점[1,2]],stime[index-저점[1,2]],var11-var13*(Per7/100),sdate,stime,var11-var13*(Per7/100)); TL_SetColor(TL12,red); TL_SetColor(TL13,red); TL_SetColor(TL14,red); TL_SetColor(TL15,red); TL_SetColor(TL16,red); TL_SetColor(TL17,red); TL_SetColor(TL18,red); }
프로필 이미지
참아람
2021-04-27
794
글번호 148431
지표
답변완료

문의 드립니다.

input : P(60),P1(120); var1 = ma(C,P); if var1 > var1[1] Then var2 = 1; if var1 < var1[1] Then var2 = -1; if var2 == 1 Then plot1(var1,"이평",RED,DEF,4); Else plot1(var1,"이평",BLACK,DEF,4); Var3 = ma(C,P1); if Var3 > Var3[1] Then Var4 = 1; if Var3 < Var3[1] Then Var4 = -1; if Var4 == 1 Then Plot2(Var3,"이평1",RED,DEF,6); Else plot2(Var3,"이평1",BLACK,DEF,6); ===================================================== 안녕하세요. 고생 너무 많으십니다. 문의 드리는데요 이 60, 120 이평선 골든 크로스 되면 화살표 나오는 방법을 문의 해봅니다.ㅜㅜ 60, 120이평선 골든 크로스 하면 빨간색 화살표 나오게 하고 싶고 60, 120이평선 데드 크로스 하면 파란색 화살표 나오게 하고 싶습니다. 이방법은 지표 이라는 문서에서 넣고 하는 건가요? 아니면 시스템 문서 인가요? 감사합니다.
프로필 이미지
스오어스
2021-04-27
857
글번호 148430
지표

수서동ㅇ병아리 님에 의해서 삭제되었습니다.

프로필 이미지
수서동ㅇ병아리
2021-04-27
60
글번호 148428
시스템
답변완료

수식변경 부탁드립니다.

아래 트레이딩뷰 지표(SuperTrend MTF Headtmap) 수식변경 부탁드립니다. 1. 지표와 전략 두개로 작성 부탁드립니다. 함수로 작성하여 분리해주셔도 감사하겠습니다. 총 4개 주기를 각각 지정가능했으면 좋겠고, 긴 주기 2개가 상승추세일때 아래주기 두개가 하락>상승추세로 바뀔경우 매수, 반대의 경우 매도입니다. 2. 추세색상(형광, 빨강) 이외에 추세전환전 옅게 색칠되는 부분이 잘 보였으면 좋겠습니다. //@version=4 study("Supertrend MTF Heatmap", shorttitle="Supertrend MTF Heatmap", overlay=false, precision=6) Factor=input(3,title="[SUPERTREND] Factor", minval=1,maxval = 100, type=input.float) Pd=input(7, title="[SUPERTREND] PD", minval=1,maxval = 100) res1 = input("60", type=input.resolution, title="First Timeframe") res2 = input("120", type=input.resolution, title="Second Timeframe") res3 = input("240", type=input.resolution, title="Third Timeframe") res4 = input("D", type=input.resolution, title="Fourth Timeframe") res5 = input("W", type=input.resolution, title="Fifth Timeframe") Supertrend(Factor, Pd) => Up=hl2-(Factor*atr(Pd)) Dn=hl2+(Factor*atr(Pd)) TrendUp = 0.0 TrendUp := close[1]>TrendUp[1] ? max(Up,TrendUp[1]) : Up TrendDown = 0.0 TrendDown := close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn Trend = 0.0 Trend := close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1) Tsl = Trend==1? TrendUp: TrendDown S_Buy = Trend == 1 ? 1 : 0 S_Sell = Trend != 1 ? 1 : 0 [Trend, Tsl] [Trend,Tsl] = Supertrend(Factor, Pd) // Security ST1_Trend_MTF = security(syminfo.tickerid, res1, Trend[1], lookahead=barmerge.lookahead_on) ST2_Trend_MTF = security(syminfo.tickerid, res2, Trend[1], lookahead=barmerge.lookahead_on) ST3_Trend_MTF = security(syminfo.tickerid, res3, Trend[1], lookahead=barmerge.lookahead_on) ST4_Trend_MTF = security(syminfo.tickerid, res4, Trend[1], lookahead=barmerge.lookahead_on) ST5_Trend_MTF = security(syminfo.tickerid, res5, Trend[1], lookahead=barmerge.lookahead_on) h0 = hline(1, color=color.new(color.black, 10), linewidth=2, linestyle=hline.style_solid) h1 = hline(2, color=color.new(color.black, 10), linewidth=2, linestyle=hline.style_solid) h2 = hline(3, color=color.new(color.black, 10), linewidth=2, linestyle=hline.style_solid) h3 = hline(4, color=color.new(color.black, 10), linewidth=2, linestyle=hline.style_solid) h4 = hline(5, color=color.new(color.black, 10), linewidth=2, linestyle=hline.style_solid) h5 = hline(6, color=color.new(color.black, 10), linewidth=2, linestyle=hline.style_solid) get_bars(Trend)=> since_st_buy = barssince(Trend == 1) since_st_sell = barssince(Trend == -1) [since_st_buy, since_st_sell] [since_st_1_buy, since_st_1_sell] = get_bars(ST1_Trend_MTF) [since_st_2_buy, since_st_2_sell] = get_bars(ST2_Trend_MTF) [since_st_3_buy, since_st_3_sell] = get_bars(ST3_Trend_MTF) [since_st_4_buy, since_st_4_sell] = get_bars(ST4_Trend_MTF) [since_st_5_buy, since_st_5_sell] = get_bars(ST5_Trend_MTF) // selec the right heatmsap color heatmap_color(cond1, cond2) => cond1 ? color.new(color.green, 20) : cond2 ? color.new(color.red, 20) : na lapos_x = timenow + round(change(time)*3) lapos_y = highest(5)// + (0.15 * highest(20)) // Displays the timeframe labels at the right f_draw_label(x,y,_text,_textcolor, _size)=> var label Label = na label.delete(Label) Label := label.new(x, y, _text, color=color.new(color.white, 20), textcolor=_textcolor, style=label.style_none, yloc=yloc.price, xloc=xloc.bar_time, size=_size) // Display the labels in a more readable way // If timeframe seleced is "Same as symbol" displays the timeframe.period string value res_to_string(res)=> str = iff(res == "1", "m1", iff(res == "5", "m5", iff(res == "15", "m15", iff(res == "30", "m30", iff(res == "60", "H1", iff(res == "120", "H2", iff(res == "240", "H4", iff(res == "480", "H8", iff(res == "D", "Daily", iff(res == "W", "Weekly", iff(res == "360", "H3", timeframe.period))))))))))) str // draw the TF labels f_draw_label(lapos_x, 1, res_to_string(res1), color.black, size.large) f_draw_label(lapos_x, 2, res_to_string(res2), color.black, size.large) f_draw_label(lapos_x, 3, res_to_string(res3), color.black, size.large) f_draw_label(lapos_x, 4, res_to_string(res4), color.black, size.large) f_draw_label(lapos_x, 5, res_to_string(res5), color.black, size.large) // Draw the green/red heatmap raws fill(h0 ,h1, color=heatmap_color(since_st_1_sell>since_st_1_buy, since_st_1_sell<since_st_1_buy)) fill(h1, h2, color=heatmap_color(since_st_2_sell>since_st_2_buy, since_st_2_sell<since_st_2_buy)) fill(h2, h3, color=heatmap_color(since_st_3_sell>since_st_3_buy, since_st_3_sell<since_st_3_buy)) fill(h3, h4, color=heatmap_color(since_st_4_sell>since_st_4_buy, since_st_4_sell<since_st_4_buy)) fill(h4, h5, color=heatmap_color(since_st_5_sell>since_st_5_buy, since_st_5_sell<since_st_5_buy))
프로필 이미지
dandan
2021-04-27
1526
글번호 148427
지표
답변완료

수식변경 부탁드립니다.

아래 TradingView 수식(Donchian Trend Ribbon) 변경부탁드립니다. 1. 지표와 전략 두개로 작성 부탁드립니다. 함수로 작성하여 분리해주셔도 감사하겠습니다. 매매기준은 색상변환시 입니다. 2. 추세색상(형광, 빨강) 이외에 추세전환전 옅게 색칠되는 부분이 잘 보였으면 좋겠습니다. // 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("Donchian Trend Ribbon") dlen = input(defval = 20, title = "Donchian Channel Period", minval = 10) dchannel(len)=> float hh = highest(len) float ll = lowest(len) int trend = 0 trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1]) trend dchannelalt(len, maintrend)=> float hh = highest(len) float ll = lowest(len) int trend = 0 trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1]) trendcolor = maintrend == 1 ? trend == 1 ? #00FF00ff : #00FF009f : maintrend == -1 ? trend == -1 ? #FF0000ff : #FF00009f : na trendcolor maintrend = dchannel(dlen) plot(05, color = dchannelalt(dlen - 0, maintrend), style = plot.style_columns, histbase=00) plot(10, color = dchannelalt(dlen - 1, maintrend), style = plot.style_columns, histbase=05) plot(15, color = dchannelalt(dlen - 2, maintrend), style = plot.style_columns, histbase=10) plot(20, color = dchannelalt(dlen - 3, maintrend), style = plot.style_columns, histbase=15) plot(25, color = dchannelalt(dlen - 4, maintrend), style = plot.style_columns, histbase=20) plot(30, color = dchannelalt(dlen - 5, maintrend), style = plot.style_columns, histbase=25) plot(35, color = dchannelalt(dlen - 6, maintrend), style = plot.style_columns, histbase=30) plot(40, color = dchannelalt(dlen - 7, maintrend), style = plot.style_columns, histbase=35) plot(45, color = dchannelalt(dlen - 8, maintrend), style = plot.style_columns, histbase=40) plot(50, color = dchannelalt(dlen - 9, maintrend), style = plot.style_columns, histbase=45)
프로필 이미지
dandan
2021-04-27
1561
글번호 148426
지표
답변완료

수식변경 부탁드립니다.

아래 TradingView 수식(SuperTrend MTF Heikin Ashi) 변경부탁드립니다. 1. 지표와 전략 두개로 작성 부탁드립니다. 함수로 작성하여 분리해주셔도 감사하겠습니다. 매매기준은 다음과 같습니다. 매수 : TimeFrame이 높은 것이 상승중일때, TimeFrame낮은것이 상승전환 시 매수 매도 : TimeFrame이 높은 것이 하락중일때, TimeFrame낮은것이 하락전환 시 매도 2. 지표에서 지정되는 High TimeFrame 은 굳이 Auto로 안해주셔도 되며, 직접 지정할 수 있었으면 좋겠습니다. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // &#169; LonesomeTheBlue // // Author : LonesomeTheBlue // //@version=4 study("Supertrend MTF Heikin Ashi", overlay = true) mode =input(title = "HTF Method", defval = 'Auto', options=['Auto', 'User Defined']) //auto higher time frame HTFo =timeframe.period == '1' ? '5' : timeframe.period == '3' ? '15' : timeframe.period == '5' ? '15' : timeframe.period == '15' ? '60' : timeframe.period == '30' ? '120' : timeframe.period == '45' ? '120' : timeframe.period == '60' ? '240' : timeframe.period == '120' ? '240' : timeframe.period == '180' ? '240' : timeframe.period == '240' ? 'D' : timeframe.period == 'D' ? 'W' : '5W' HTFm = input('5', title = "Time Frame (if HTF Method=User Defined)", type=input.resolution) HTF = mode == 'Auto' ? HTFo : HTFm Mult = input(defval = 2.0, title = "ATR Factor", minval = 0.5, maxval = 100, step = 0.1) Period = input(defval = 7, title = "ATR Period", minval = 1,maxval = 100) // current time frame //Heikin Ashi high, low, close h = security(heikinashi(syminfo.tickerid), timeframe.period, high) l = security(heikinashi(syminfo.tickerid), timeframe.period, low) c = security(heikinashi(syminfo.tickerid), timeframe.period, close) //HeikinAshi atr Atr = security(heikinashi(syminfo.tickerid), timeframe.period, atr(Period)) Up = (h + l) / 2 - (Mult * Atr) Dn = (h + l) / 2 + (Mult * Atr) float TUp = na float TDown = na Trend = 0 TUp := c[1] > TUp[1] ? max(Up,TUp[1]) : Up TDown := c[1] < TDown[1] ? min(Dn,TDown[1]) : Dn Trend := c > TDown[1] ? 1: c < TUp[1]? -1: nz(Trend[1],1) Trailingsl = Trend == 1 ? TUp : TDown linecolor = Trend == 1 and nz(Trend[1]) == 1 ? color.lime : Trend == -1 and nz(Trend[1]) == -1 ? color.red : na plot(Trailingsl, color = linecolor , linewidth = 2, title = "SuperTrend") // Higher Time Frame ////// HTF high, low, close highhtf = security(heikinashi(syminfo.tickerid), HTF, high[1], lookahead = barmerge.lookahead_on) lowhtf = security(heikinashi(syminfo.tickerid), HTF, low[1], lookahead = barmerge.lookahead_on) closehtf = security(heikinashi(syminfo.tickerid), HTF, close[1], lookahead = barmerge.lookahead_on) // ATR for HTF HTfatr = security(heikinashi(syminfo.tickerid), HTF, atr(Period)[1], lookahead = barmerge.lookahead_on) Uphtf = abs(highhtf + lowhtf) / 2 - (Mult * HTfatr) Dnhtf = abs(highhtf + lowhtf) / 2 + (Mult * HTfatr) float TUphtf = na float TDownhtf = na TrendHtf = 0 TUphtf := closehtf[1] > TUphtf[1] ? max(Uphtf, TUphtf[1]) : Uphtf TDownhtf := closehtf[1] < TDownhtf[1] ? min(Dnhtf,TDownhtf[1]) : Dnhtf TrendHtf := closehtf > TDownhtf[1] ? 1 : closehtf < TUphtf[1] ? -1: nz(TrendHtf[1], 1) TrailingslHtf = TrendHtf == 1 ? TUphtf : TDownhtf linecolorHtf = TrendHtf == 1 and nz(TrendHtf[1]) == 1 ? color.blue : TrendHtf == -1 and nz(TrendHtf[1]) == -1 ? color.red : na st = plot(TrailingslHtf, color = linecolorHtf , linewidth = 3, title = "Supertrend HTF", transp = 0) plot(TrendHtf == 1 and TrendHtf[1] == -1 ? TrailingslHtf : na, title="Supertrend HTF Trend Up", linewidth = 4, color=color.blue, transp=0, style = plot.style_circles) plot(TrendHtf == -1 and TrendHtf[1] == 1 ? TrailingslHtf : na, title="Supertrend HTF Trend Down", linewidth = 4, color=color.red, transp=0, style = plot.style_circles) //Alerts alertcondition(Trend == 1 and Trend[1] == -1, title='Supertrend Trend Up', message='Supertrend Trend Up') alertcondition(Trend == -1 and Trend[1] == 1, title='Supertrend Trend Down', message='Supertrend Trend Down') alertcondition(TrendHtf == 1 and TrendHtf[1] == -1, title='Supertrend HTF Trend Up', message='Supertrend HTF Trend Upl') alertcondition(TrendHtf == -1 and TrendHtf[1] == 1, title='Supertrend HTF Trend Down', message='Supertrend HTF Trend Down')
프로필 이미지
dandan
2021-04-27
1486
글번호 148425
지표
답변완료

수식변경 부탁드립니다.

아래 TradingView 수식(Adaptive ATR-ADX Trend v2) 변경부탁드립니다. 1. 기존과 똑같이 ATR, ATR Multiplier(ADX Rising), ATR Multiplier(ADX Falling), Interval, ADX, BandPip, ADX Threshold 등 모든 변수들의 변경이 가능했으면 좋겠습니다. 2. Interval 옵션은 반드시 변경가능했으면 좋겠습니다. 3. Default옵션인 ADX Above Threshold uses ATR Falling Multiplier Even if Rising?도 항시 체크상태였으면 좋겠습니다. 4. 지표와 전략 두개로 작성 부탁드립니다. 함수로 작성하여 분리해주셔도 감사하겠습니다. //@version=3 // Constructs the trailing ATR stop above or below the price, and switches // directions when the source price breaks the ATR stop. Uses the Average // Directional Index (ADX) to switch between ATR multipliers. The higher // multiplier is used when the ADX is rising, and the lower ATR multiplier // is used with the ADX is falling. This ADX criteria further widens the gap // between the source price and the trailing ATR stop when the price is trending, // and lessens the gap between the ATR and the price when then price is not // trending. // // The ATR-ADX stop is effectively a double adapative stop that trails the price, // by both adapting to the true range of the price, and the average directional // change. When the stop is below the price (long trade) the value never decreases // until the price intersects the stop, and it reverses to being above the price // (short trade). When the stop is above the price it will never increase until // it is intersected by the price. As the true range and ADX change, the stop // will move more quickly or more slowly. // http://www.fxtsp.com/1287-doubly-adaptive-profit-average-true-range-objectives/ study(title = "Adaptive ATR-ADX Trend Multi-Timeframe", shorttitle = "Adaptive ATR Multi", overlay = true) //Mode atrLen = input(title = "ATR", type = integer, defval = 14, minval = 1, maxval = 100) m1 = input(title = "ATR Multiplier - ADX Rising", type = float, defval = 3.5, minval = 1, step = 0.1, maxval = 100) m2 = input(title = "ATR Multiplier - ADX Falling", type = float, defval = 1.75, minval = 1, step = 0.1, maxval = 100) dintval = input(title = "Inverval (i.e. 15, 60, 240, D, W)", defval = '60') useIntval = input(false, title = "Use Chart Interval") bandHalfWidth = input(1, title = "Band Pip/Tick Size Around Stop", minval = 0) showBand = input(false, title = "Use Band Around Stop?") adxLen = input(title = "ADX", type = integer, defval = 14, minval = 1, maxval = 100) adxThresh = input(title = "ADX Threshold", type = integer, defval = 25, minval = 1) aboveThresh = input(true, title = "ADX Above Threshold uses ATR Falling Multiplier Even if Rising?") useHeikin = input(false, title = "Use Heikin-Ashi Bars (Source will be ohlc4)") src = ohlc4 tk = syminfo.mintick blockMult = tk < 0.1 and (tk != 0.01 or syminfo.pointvalue < 10 or syminfo.pointvalue * tk <= 1) and (tk != 0.001 or syminfo.pointvalue <= 1) and tk != 0.005 and tk != 0.0001 and tk != 0.0005 and tk != 0.03125 and tk != 0.015625 ? tk == 0.00005 or tk * 100 == 0.00005 ? 2 : 10 : 1 block = tk * blockMult atrCalc() => // DI-Pos, DI-Neg, ADX hR = change(high) lR = -change(low) dmPos = hR > lR ? max(hR, 0) : 0 dmNeg = lR > hR ? max(lR, 0) : 0 sTR = tr sTR := nz(sTR[1]) - nz(sTR[1]) / adxLen + tr sDMPos = tr sDMPos := nz(sDMPos[1]) - nz(sDMPos[1]) / adxLen + dmPos sDMNeg = tr sDMNeg := nz(sDMNeg[1]) - nz(sDMNeg[1]) / adxLen + dmNeg DIP = sDMPos / sTR * 100 DIN = sDMNeg / sTR * 100 DX = abs(DIP - DIN) / (DIP + DIN) * 100 adx = sma(DX, adxLen) // Heikin-Ashi xClose = ohlc4 xOpen = open xOpen := (nz(xOpen[1]) + nz(xClose[1])) / 2 xHigh = max(high, max(xOpen, xClose)) xLow = min(low, min(xOpen, xClose)) // Trailing ATR v1 = abs(xHigh - xClose[1]) v2 = abs(xLow - xClose[1]) v3 = xHigh - xLow trueRange = max(v1, max(v2, v3)) atr = useHeikin ? rma(trueRange, atrLen) : atr(atrLen) m = m1 m := rising(adx, 1) and (adx < adxThresh or not aboveThresh) ? m1 : falling(adx, 1) or (adx > adxThresh and aboveThresh) ? m2 : nz(m[1]) mUp = DIP >= DIN ? m : m2 mDn = DIN >= DIP ? m : m2 src_ = useHeikin ? (xOpen + xHigh + xLow + xClose) / 4 : src c = useHeikin ? xClose : close t = useHeikin ? (xHigh + xLow) / 2 : hl2 up = t - mUp * atr dn = t + mDn * atr TUp = close TUp := max(src_[1], max(c[1], close[1])) > TUp[1] ? max(up, TUp[1]) : up TDown = close TDown := min(src_[1], min(c[1], close[1])) < TDown[1] ? min(dn, TDown[1]) : dn trend = 1 trend := min(src_, min(c, close)) > TDown[1] ? 1 : max(src_, max(c, close)) < TUp[1]? -1 : nz(trend[1], 1) // ceil positive trend to nearest pip/tick, floor negative trend to nearest pip/tick stop = trend == 1 ? ceil(TUp / block) * block : floor(TDown / block) * block trendChange = change(trend) [adx, trend, stop, trendChange] [adx, _trend, _stop, _trendChange] = atrCalc() start = security(tickerid, dintval, time, lookahead = true) newSession = iff(change(start), 1, 0) sinceNew = barssince(newSession) // Fixes intervals that are uneven, i.e. 120 on normal 6.5 hour NYSE day // This will happen if a 2H interval closes at 4:00 EST but opened at 3:30 // EST. This is a new session candle. The 9:30 open the next day will also // be a new session candle, which shouldn't happen. There should never be // 2 consecutive candles that are new session candles, unless the indicator // interval is less than or equal to the chart interval. If there are 3 // consecutive candles where each candle is a new session, then the chart // interval is <= the declared indicator interval. isChartIntval = sinceNew == 0 and sinceNew[1] == 0 and sinceNew[2] == 0 trend = useIntval or isChartIntval ? _trend : security(tickerid, dintval, _trend[1], lookahead = true) stop = useIntval or isChartIntval ? _stop : security(tickerid, dintval, _stop[1], lookahead = true) trendChange = useIntval or isChartIntval ? _trendChange : security(tickerid, dintval, _trendChange[1], lookahead = true) // Plot upC = #00FF00DD dnC = #FF0000DD upC2 = #00FF0037 dnC2 = #FF000037 trans = #00000000 lineColor = not(trendChange) or trendChange[1] ? trend > 0 ? upC : dnC : trans fillColor = not(trendChange) or trendChange[1] ? trend > 0 ? upC2 : dnC2 : trans // Can't figure out any other way to solve this issue for fixing a problem where // the indicator interval is greater than the chart interval, and the indicator is // not divisible by the chart interval without a remainder. oddIntervalTest = (lineColor[1] == upC and lineColor[0] == dnC) or (lineColor[1] == dnC and lineColor[0] == upC) stopColor = oddIntervalTest ? trans : lineColor trendChangeReal = stopColor == trans shapeColor = trendChangeReal ? trend > 0 ? #00FF00F8 : #FF0000F8 : trans upperBand = stop + bandHalfWidth * block lowerBand = stop - bandHalfWidth * block stopPlot = plot(stop, color = stopColor, title = "ATR-ADX Trend") upper = plot(showBand ? upperBand : na, color = oddIntervalTest ? trans : lineColor, style = circles) lower = plot(showBand ? lowerBand : na, color = oddIntervalTest ? trans : lineColor, style = circles) fill(upper, stopPlot, title = "ATR Band Fill - Upper", color = fillColor) fill(lower, stopPlot, title = "ATR Band Fill - Lower", color = fillColor) plotshape(trendChangeReal ? stop : na, style = shape.circle, size = size.tiny, location = location.absolute, color = shapeColor, title = "Trend Change") // alerts alertcondition(trendChangeReal and trend > 0, "Adaptive ATR-ADX Trend Change Up", "Adaptive ATR-ADX Trend Change Up") alertcondition(trendChangeReal and trend < 0, "Adaptive ATR-ADX Trend Change Down", "Adaptive ATR-ADX Trend Change Down") alertcondition(not trendChangeReal and ((crossunder(low, stop) and trend > 0) or (crossover(high, stop) and trend < 0)), "Adaptive ATR-ADX Trend Retest", "Adaptive ATR-ADX Trend Retest") // end
프로필 이미지
dandan
2021-04-27
1698
글번호 148424
지표
답변완료

Rsi 지표를,,,

직접 만들어서 적용해 보려 하는데요,,, 만드는 공식 좀 알려주시면 감사하겠습니다.
프로필 이미지
클레멘타인
2021-04-27
1190
글번호 148423
지표