커뮤니티

부탁드립니다.

프로필 이미지
thegin
2020-02-27 16:30:13
380
글번호 136422
답변완료
StudyName = "CI" ShortStudyName = "I" study(StudyName, shorttitle=ShortStudyName, overlay=true, precision=6) source = input(close) cci_period = input(28, "CCI Period") cci = cci(source, cci_period) //UL = input(80, "Upper level") //LL = input(20, "Lower Level") ML = input(0, "CCI Mid Line pivot") Factor=input(3,title="[ST] Factor", minval=1,maxval = 100, type=input.float) Pd=input(3, title="[ST] PD", minval=1,maxval = 100) f_supertrend(Factor, Pd) => Up=hl2-(Factor*atr(Pd)) Dn=hl2+(Factor*atr(Pd)) TrendUp = 0.0 TrendUp := cci[1] > ML ? max(Up,TrendUp[1]) : Up TrendDown = 0.0 TrendDown := cci[1]< ML ? min(Dn,TrendDown[1]) : Dn Trend = 0.0 Trend := cci > ML ? 1: cci < ML ? -1: nz(Trend[1],1) Tsl = Trend==1? TrendUp: TrendDown Tsl st_tsl = f_supertrend(Factor, Pd) // Plot the ST linecolor = close >= st_tsl ? color.green : color.red plot(st_tsl, color = linecolor , linewidth = 4,title = "SuperTrend", transp=0) //hline(UL, title="Upper Line", linestyle=hline.style_solid, linewidth=1, color=color.red) //hline(LL, title="Lower Line", linestyle=hline.style_solid, linewidth=1, color=color.lime) //hline(ML, title="Mid Line", linestyle=hline.style_solid, linewidth=2, color=color.gray) 감사합니다.
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2020-02-28 11:12:35

안녕하세요 예스스탁입니다. input : cci_period(28),ML(0),Factor(3),Pd(3); var : source(0),cciv(0),atrv(0),hl2(0),upv(0),dnv(0),linecolor(0); var : TrendUp(0),TrendDown(0),Trend(0),st_tsl(0); source = close; cciv = cci(cci_period); atrv = atr(Pd); hl2 = (H+L)/2; Upv=hl2-(Factor*atrv); Dnv=hl2+(Factor*atrv); if CurrentBar >= 1 then { TrendUp = 0; TrendUp = iff(cciv[1] > ML,max(Upv,TrendUp[1]),Upv); TrendDown = 0; TrendDown = iff(cciv[1] < ML,min(Dnv,TrendDown[1]),Dnv); Trend = 0; Trend = iff(cciv > ML, 1,iff(cciv < ML, -1, Trend[1])); st_tsl = iff(Trend==1 ,TrendUp,TrendDown); linecolor = iff(close >= st_tsl,green,red); plot1(st_tsl,"SuperTrend",linecolor); } 즐거운 하루되세요 > thegin 님이 쓴 글입니다. > 제목 : 부탁드립니다. > StudyName = "CI" ShortStudyName = "I" study(StudyName, shorttitle=ShortStudyName, overlay=true, precision=6) source = input(close) cci_period = input(28, "CCI Period") cci = cci(source, cci_period) //UL = input(80, "Upper level") //LL = input(20, "Lower Level") ML = input(0, "CCI Mid Line pivot") Factor=input(3,title="[ST] Factor", minval=1,maxval = 100, type=input.float) Pd=input(3, title="[ST] PD", minval=1,maxval = 100) f_supertrend(Factor, Pd) => Up=hl2-(Factor*atr(Pd)) Dn=hl2+(Factor*atr(Pd)) TrendUp = 0.0 TrendUp := cci[1] > ML ? max(Up,TrendUp[1]) : Up TrendDown = 0.0 TrendDown := cci[1]< ML ? min(Dn,TrendDown[1]) : Dn Trend = 0.0 Trend := cci > ML ? 1: cci < ML ? -1: nz(Trend[1],1) Tsl = Trend==1? TrendUp: TrendDown Tsl st_tsl = f_supertrend(Factor, Pd) // Plot the ST linecolor = close >= st_tsl ? color.green : color.red plot(st_tsl, color = linecolor , linewidth = 4,title = "SuperTrend", transp=0) //hline(UL, title="Upper Line", linestyle=hline.style_solid, linewidth=1, color=color.red) //hline(LL, title="Lower Line", linestyle=hline.style_solid, linewidth=1, color=color.lime) //hline(ML, title="Mid Line", linestyle=hline.style_solid, linewidth=2, color=color.gray) 감사합니다.