커뮤니티

수고하십니다

프로필 이미지
비듬싸순
2024-10-26 06:35:34
872
글번호 184626
답변완료

첨부 이미지

항상감사드리며 트레이딩뷰 챠트인데 간곡히 변환 부탁드립니다 indicator("Market Structure Algo", "MS Algo", true) left = input.int(5, "Internal MS", minval = 2) left1 = input.int(30, "External MS", minval = 7) dist = input.float(2.00, "Zone Distance", minval = 1, step = 0.1, inline = "zone") zone = input.bool(true, "", inline = "zone") right = left right1 = left1 upcolor = input.color(#2962ff, "Positive color", group = "Appearence") downcolor = input.color(#e91e63, "Negative color", group = "Appearence") // Internal pvh = ta.pivothigh(left, right) pvl = ta.pivotlow(left, right) var float ph = na var float pl = na ph := pvh != 0 ? pvh : ph[1] pl := pvl != 0 ? pvl : pl[1] currenth = ta.valuewhen(pvh != 0, high[right], 0) lasth = ta.valuewhen(pvh != 0, high[right], 1) currentl = ta.valuewhen(pvl != 0, low[right], 0) lastl = ta.valuewhen(pvl != 0, low[right], 1) var int ms = na ms := if currenth > lasth and currentl > lastl and close > ph ms := 2 else if close > ph ms := 1 else if currenth < lasth and currentl < lastl and close < pl ms := -2 else if close < pl ms := -1 else ms[1] var int last = na longsig = close > ph and ms[1] < 0 shortsig = close < pl and ms[1] > 0 longsig1 = close > ph and ms[1] > 0 shortsig1 = close < pl and ms[1] < 0 longsig2 = longsig1 and longsig1[1] == false and longsig[1] == false shortsig2 = shortsig1 and shortsig1[1] == false and shortsig[1] == false longexit = high > ph and close < ph shortexit = low < pl and close > pl // External pvh1 = ta.pivothigh(left1, right1) pvl1 = ta.pivotlow(left1, right1) var float ph1 = na var float pl1 = na ph1 := pvh1 != 0 ? pvh1 : ph1[1] pl1 := pvl1 != 0 ? pvl1 : pl1[1] // Zone ma = ta.sma(close, left1) atr = ta.atr(left1) ma2 = ms > 0 and ms[1] > 0 ? ma - atr * dist : ms < 0 and ms[1] < 0 ? ma + atr*dist : na ma3 = ms > 0 and ms[1] > 0 ? ma2 + atr : ms < 0 and ms[1] < 0 ? ma2 - atr : na // Plot if pvh != 0 l1 = line.new(x1 = bar_index - right, y1 = ph, x2 = bar_index + math.round(right/2), y2 = ph, color = color.new(upcolor, 50), style = line.style_dashed) if pvl != 0 l2 = line.new(x1 = bar_index - right, y1 = pl, x2 = bar_index + math.round(right/2), y2 = pl, color = color.new(downcolor, 50), style = line.style_dashed) if pvh1 != 0 l3 = line.new(x1 = bar_index - right1, y1 = ph1, x2 = bar_index + math.round(right1/2), y2 = ph1, color = upcolor, width = 2) if pvl1 != 0 l4 = line.new(x1 = bar_index - right1, y1 = pl1, x2 = bar_index + math.round(right1/2), y2 = pl1, color = downcolor, width = 2) barcolor(ms >= 2 ? upcolor : ms == 1 ? color.new(upcolor, 50) : ms <= -2 ? downcolor : ms == -1 ? color.new(downcolor, 50) : na) plotshape(longsig, "Long Signal", shape.labelup, location.belowbar, upcolor, 0, "↑", textcolor = color.new(color.white, 50)) plotshape(longsig2, "Buy Signal", shape.triangleup, location.belowbar, upcolor) plotshape(shortsig, "Short Signal", shape.labeldown, location.abovebar, downcolor, 0, "↓", textcolor = color.new(color.white, 50)) plotshape(shortsig2, "Sell Signal", shape.triangledown, location.abovebar, downcolor) plotshape(longexit, "Long Exit", shape.triangledown, location.abovebar, color.gray) plotshape(shortexit, "Short Exit", shape.triangleup, location.belowbar, color.gray) p1 = plot(zone ? ma2 : na, "External Zone", close > ma2 ? upcolor : close < ma2 ? downcolor : na, 1, plot.style_linebr) p2 = plot(zone ? ma3 : na, "Internal Zone", close > ma2 ? color.new(upcolor, 80) : close < ma2 ? color.new(downcolor, 80) : na, 1, plot.style_linebr) fill(p1, p2, color = close > ma2 ? color.new(upcolor, 80) : color.new(downcolor, 80), title = "Zone fill") alertcondition(longsig, "Long CHoCH") alertcondition(shortsig, "Short CHoCH") alertcondition(longsig2, "Long BOS") alertcondition(shortsig2, "Short BOS")
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2024-10-28 10:45:41

안녕하세요 예스스탁입니다. input : left(5),right(5); input : left1(30),right1(30); input : dist(2.00); input : upcolor(Blue); input : downcolor(Red); var : ph(0),currenth(0),lasth(0),pl(0),currentl(0),lastl(0); var : ms(0),l1(0),l2(0),l3(0),l4(0); if SwingHigh(1,H,left,right,Left+right+1) != -1 Then { ph = H[right]; currenth = h[right]; lasth = currenth[1]; l1 = TL_New(sDate[right],sTime[right],ph,sDate,sTime,ph); TL_SetColor(l1,upcolor); TL_SetStyle(l1,3); var1 = Index; } Else { if var1 > 0 and Index <= var1+Round(Right/2,0) Then TL_SetEnd(l1,sDate,sTime,ph); } if Swinglow(1,L,left,right,Left+right+1) != -1 Then { pl = L[right]; currentl = l[right]; lastl = currentl[1]; l2 = TL_New(sDate[right],sTime[right],pl,sDate,sTime,pl); TL_SetColor(l2,downcolor); TL_SetStyle(l2,3); var2 = Index; } Else { if var2 > 0 and Index <= var2+Round(Right/2,0) Then TL_SetEnd(l2,sDate,sTime,pl); } if currenth > lasth and currentl > lastl and close > ph Then ms = 2; else if currenth < lasth and currentl < lastl and close < pl Then ms = -2; else if close > ph Then ms = 1; else if close < pl Then ms = -1; var : longsig(False),shortsig(False),longsig1(False),shortsig1(False); var : longsig2(False),shortsig2(false),longexit(False),shortexit(False); var : ph1(0),pl1(0),mav(0),a(0),ma2(0),ma3(0); longsig = close > ph and ms[1] < 0; shortsig = close < pl and ms[1] > 0; longsig1 = close > ph and ms[1] > 0; shortsig1 = close < pl and ms[1] < 0; longsig2 = longsig1 and longsig1[1] == false and longsig[1] == false; shortsig2 = shortsig1 and shortsig1[1] == false and shortsig[1] == false; longexit = high > ph and close < ph; shortexit = low < pl and close > pl; if SwingHigh(1,H,left1,right1,Left1+right1+1) != -1 Then { ph1 = H[right1]; l3 = TL_New(sDate[right1],sTime[right1],ph1,sDate,sTime,ph1); TL_SetColor(l3,upcolor); TL_SetDrawMode(l3,0); var3 = Index; } Else { if var3 > 0 and Index <= var3+Round(Right1/2,0) Then TL_SetEnd(l3,sDate,sTime,ph1); } if Swinglow(1,L,left1,right1,Left1+right1+1) != -1 Then { pl1 = L[right1]; l4 = TL_New(sDate[right1],sTime[right1],pl1,sDate,sTime,pl1); TL_SetColor(l4,downcolor); TL_SetDrawMode(l4,0); var4 = Index; } Else { if var4 > 0 and Index <= var4+Round(Right1/2,0) Then TL_SetEnd(l4,sDate,sTime,pl1); } // Zone mav = ma(close, left1); a = atr(left1); ma2 = iff(ms > 0 and ms[1] > 0 , mav - a * dist ,IFf( ms < 0 and ms[1] < 0 , mav + a*dist , Nan)); ma3 = iff(ms > 0 and ms[1] > 0 , ma2 + a ,IFf( ms < 0 and ms[1] < 0 , ma2 - a , Nan)); var : tx1(0),tx2(0),tx3(0),tx4(0),tx5(0),tx6(0); if longsig Then { tx1 = Text_New(sDate,sTime,L,"↑"); Text_SetStyle(tx1,2,0); Text_SetColor(tx1,Blue); } if longsig2 Then { tx2 = Text_New(sDate,sTime,L,"↑"); Text_SetStyle(tx2,2,0); Text_SetColor(tx2,Blue); } if shortsig Then { tx3 = Text_New(sDate,sTime,H,"↓"); Text_SetStyle(tx3,2,1); Text_SetColor(tx3,Red); } if shortsig2 Then { tx4 = Text_New(sDate,sTime,H,"↓"); Text_SetStyle(tx4,2,1); Text_SetColor(tx4,Red); } if longexit Then { tx5 = Text_New(sDate,sTime,H,"▼"); Text_SetStyle(tx5,2,1); } if shortexit Then { tx6 = Text_New(sDate,sTime,L,"▲"); Text_SetStyle(tx6,2,1); } plot1(ma2, "External Zone", IFf(close > ma2 , upcolor, IFf(close < ma2 , downcolor, Nan))); plot2(ma3, "Internal Zone", iff(close > ma2 , upcolor, iff(close < ma2 , downcolor, Nan))); 즐거운 하루되세요 > 비듬싸순 님이 쓴 글입니다. > 제목 : 수고하십니다 > 항상감사드리며 트레이딩뷰 챠트인데 간곡히 변환 부탁드립니다 indicator("Market Structure Algo", "MS Algo", true) left = input.int(5, "Internal MS", minval = 2) left1 = input.int(30, "External MS", minval = 7) dist = input.float(2.00, "Zone Distance", minval = 1, step = 0.1, inline = "zone") zone = input.bool(true, "", inline = "zone") right = left right1 = left1 upcolor = input.color(#2962ff, "Positive color", group = "Appearence") downcolor = input.color(#e91e63, "Negative color", group = "Appearence") // Internal pvh = ta.pivothigh(left, right) pvl = ta.pivotlow(left, right) var float ph = na var float pl = na ph := pvh != 0 ? pvh : ph[1] pl := pvl != 0 ? pvl : pl[1] currenth = ta.valuewhen(pvh != 0, high[right], 0) lasth = ta.valuewhen(pvh != 0, high[right], 1) currentl = ta.valuewhen(pvl != 0, low[right], 0) lastl = ta.valuewhen(pvl != 0, low[right], 1) var int ms = na ms := if currenth > lasth and currentl > lastl and close > ph ms := 2 else if close > ph ms := 1 else if currenth < lasth and currentl < lastl and close < pl ms := -2 else if close < pl ms := -1 else ms[1] var int last = na longsig = close > ph and ms[1] < 0 shortsig = close < pl and ms[1] > 0 longsig1 = close > ph and ms[1] > 0 shortsig1 = close < pl and ms[1] < 0 longsig2 = longsig1 and longsig1[1] == false and longsig[1] == false shortsig2 = shortsig1 and shortsig1[1] == false and shortsig[1] == false longexit = high > ph and close < ph shortexit = low < pl and close > pl // External pvh1 = ta.pivothigh(left1, right1) pvl1 = ta.pivotlow(left1, right1) var float ph1 = na var float pl1 = na ph1 := pvh1 != 0 ? pvh1 : ph1[1] pl1 := pvl1 != 0 ? pvl1 : pl1[1] // Zone ma = ta.sma(close, left1) atr = ta.atr(left1) ma2 = ms > 0 and ms[1] > 0 ? ma - atr * dist : ms < 0 and ms[1] < 0 ? ma + atr*dist : na ma3 = ms > 0 and ms[1] > 0 ? ma2 + atr : ms < 0 and ms[1] < 0 ? ma2 - atr : na // Plot if pvh != 0 l1 = line.new(x1 = bar_index - right, y1 = ph, x2 = bar_index + math.round(right/2), y2 = ph, color = color.new(upcolor, 50), style = line.style_dashed) if pvl != 0 l2 = line.new(x1 = bar_index - right, y1 = pl, x2 = bar_index + math.round(right/2), y2 = pl, color = color.new(downcolor, 50), style = line.style_dashed) if pvh1 != 0 l3 = line.new(x1 = bar_index - right1, y1 = ph1, x2 = bar_index + math.round(right1/2), y2 = ph1, color = upcolor, width = 2) if pvl1 != 0 l4 = line.new(x1 = bar_index - right1, y1 = pl1, x2 = bar_index + math.round(right1/2), y2 = pl1, color = downcolor, width = 2) barcolor(ms >= 2 ? upcolor : ms == 1 ? color.new(upcolor, 50) : ms <= -2 ? downcolor : ms == -1 ? color.new(downcolor, 50) : na) plotshape(longsig, "Long Signal", shape.labelup, location.belowbar, upcolor, 0, "↑", textcolor = color.new(color.white, 50)) plotshape(longsig2, "Buy Signal", shape.triangleup, location.belowbar, upcolor) plotshape(shortsig, "Short Signal", shape.labeldown, location.abovebar, downcolor, 0, "↓", textcolor = color.new(color.white, 50)) plotshape(shortsig2, "Sell Signal", shape.triangledown, location.abovebar, downcolor) plotshape(longexit, "Long Exit", shape.triangledown, location.abovebar, color.gray) plotshape(shortexit, "Short Exit", shape.triangleup, location.belowbar, color.gray) p1 = plot(zone ? ma2 : na, "External Zone", close > ma2 ? upcolor : close < ma2 ? downcolor : na, 1, plot.style_linebr) p2 = plot(zone ? ma3 : na, "Internal Zone", close > ma2 ? color.new(upcolor, 80) : close < ma2 ? color.new(downcolor, 80) : na, 1, plot.style_linebr) fill(p1, p2, color = close > ma2 ? color.new(upcolor, 80) : color.new(downcolor, 80), title = "Zone fill") alertcondition(longsig, "Long CHoCH") alertcondition(shortsig, "Short CHoCH") alertcondition(longsig2, "Long BOS") alertcondition(shortsig2, "Short BOS")