커뮤니티

예스로 부탁합니다.

프로필 이미지
as8282
2025-08-10 16:20:57
193
글번호 193113
답변완료
트뷰에서 알게된 지표인데 예스 수식으로 부탁합니다. 미리감사드립니다. //version=5 //author: mladen //rebound arrows and TMA angle caution: Ale //rewritten from MQL5 to Pine: Brylator indicator("TMA Centered Bands Indicator", "TMA v1.0 Gaga", overlay = true, max_lines_count = 500, max_labels_count = 500) //INPUTS var GRP1 = "Parameters" HalfLength = input.int(44, "Centered TMA half period", group = GRP1) string PriceType = input.string("Weighted", "Price to use", options = ["Close", "Open", "High", "Low", "Median", "Typical", "Weighted", "Average"], group = GRP1) AtrPeriod = input.int(120, "Average true range period", group = GRP1) AtrMultiplier = input.float(2, "Average true range multiplier", group = GRP1) TMAangle = input.int(4, "Centered TMA angle caution", group = GRP1) // APPEARANCE (เพิ่มตัวเลือกขนาดและข้อความ BUY/SELL) var GRP4 = "Appearance" arrowSizeOpt = input.string("Large", "Arrow size", options = ["Tiny", "Small", "Normal", "Large", "Huge"], group = GRP4) showBuySellText = input.bool(true, "Show BUY/SELL text on arrows", group = GRP4) buyText = input.string("BUY", "Buy text", inline = "txt", group = GRP4) sellText = input.string("SELL", "Sell text", inline = "txt", group = GRP4) // map ขนาด arrowSize = switch arrowSizeOpt "Tiny" => size.tiny "Small" => size.small "Normal" => size.normal "Large" => size.large => size.huge //VARIABLES float tmac = na float tmau = na float tmad = na var float pastTmac = na //from the previous candle var float pastTmau = na var float pastTmad = na float tmau_temp = na //before looping float tmac_temp = na float tmad_temp = na float point = syminfo.pointvalue //NEEDS MORE TESTS bool last = false //checks if a loop is needed var string alertSignal = "EMPTY" //needed for alarms to avoid repetition //COLORS var GRP2 = "Colors" var color colorBuffer = na color colorDOWN = input.color(color.new(color.red, 0), "Bear", inline = "5", group = GRP2) color colorUP = input.color(color.new(color.green, 0), "Bull", inline = "5", group = GRP2) color colorBands = input.color(color.new(#b2b5be, 0), "Bands", inline = "5", group = GRP2) bool cautionInput = input.bool(true, "Caution label", inline = "6", group = GRP2) //ALERTS var GRP3 = "Alerts (Needs to create alert manually after every change)" bool crossUpInput = input.bool(false, "Crossing up", inline = "7", group = GRP3) bool crossDownInput = input.bool(false, "Crossing down", inline = "7", group = GRP3) bool comingBackInput = input.bool(false, "Coming back", inline = "7", group = GRP3) bool onArrowDownInput = input.bool(false, "On arrow down", inline = "8", group = GRP3) bool onArrowUpInput = input.bool(false, "On arrow up", inline = "8", group = GRP3) //CLEAR LINES a_allLines = line.all if array.size(a_allLines) > 0 for p = 0 to array.size(a_allLines) - 1 line.delete(array.get(a_allLines, p)) //GET PRICE Price(x) => float price = switch PriceType "Close" => close[x] "Open" => open[x] "High" => high[x] "Low" => low[x] "Median" => (high[x] + low[x]) / 2 "Typical" => (high[x] + low[x] + close[x]) / 3 "Weighted" => (high[x] + low[x] + close[x] + close[x]) / 4 "Average" => (high[x] + low[x] + close[x] + open[x])/ 4 price //MAIN for i = HalfLength to 0 //ATR atr = 0.0 for j = 0 to AtrPeriod - 1 atr += math.max(high[i + j + 10], close[i + j + 11]) - math.min(low[i + j + 10], close[i + j + 11]) atr /= AtrPeriod //BANDS sum = (HalfLength + 1) * Price(i) sumw = (HalfLength + 1) k = HalfLength for j = 1 to HalfLength sum += k * Price(i + j) sumw += k if (j <= i) sum += k * Price(i - j) sumw += k k -= 1 tmac := sum/sumw tmau := tmac+AtrMultiplier*atr tmad := tmac-AtrMultiplier*atr //ALERTS if i == 0 //Only on a real candle if (high > tmau and alertSignal != "UP") //crossing up band if crossUpInput == true //checks if activated alert("Crossing up Band") //calling alert alertSignal := "UP" //to avoid repeating else if (low < tmad and alertSignal != "DOWN") //crossing down band if crossDownInput == true alert("Crossing down Band") alertSignal := "DOWN" else if (alertSignal == "DOWN" and high >= tmad and alertSignal != "EMPTY") //back from the down band if comingBackInput == true alert("Coming back") alertSignal := "EMPTY" else if (alertSignal == "UP" and low <= tmau and alertSignal != "EMPTY") //back from the up band if comingBackInput == true alert("Coming back") alertSignal := "EMPTY" //CHANGE TREND COLOR if pastTmac != 0.0 if tmac > pastTmac colorBuffer := colorUP if tmac < pastTmac colorBuffer := colorDOWN //SIGNALS reboundD = 0.0 reboundU = 0.0 caution = 0.0 if pastTmac != 0.0 if (high[i + 1] > pastTmau and close[i + 1] > open[i + 1] and close < open) reboundD := high + AtrMultiplier * atr / 2 if (tmac - pastTmac > TMAangle * point) caution := reboundD + 10 * point if (low[i + 1] < pastTmad and close[i + 1] < open[i + 1] and close > open) reboundU := low - AtrMultiplier * atr / 2 if (pastTmac - tmac > TMAangle * point) caution := reboundU - 10 * point //LAST REAL if barstate.islast and i == HalfLength last := true tmau_temp := tmau tmac_temp := tmac tmad_temp := tmad //DRAW HANDICAPPED BANDS if barstate.islast and i < HalfLength line.new(bar_index - (i + 1), pastTmau, bar_index - (i), tmau, width = 2, style = line.style_dotted, color = colorBands) line.new(bar_index - (i + 1), pastTmac, bar_index - (i), tmac, width = 2, style = line.style_dotted, color = colorBuffer) line.new(bar_index - (i + 1), pastTmad, bar_index - (i), tmad, width = 2, style = line.style_dotted, color = colorBands) //DRAW SIGNALS (ลูกศรใหญ่ขึ้น + มีคำว่า SELL/BUY) if reboundD != 0 txtDown = showBuySellText ? "▼₩n" + sellText : "▼" label.new(bar_index - (i), reboundD, txtDown, color = na, style = label.style_label_center, textcolor = colorDOWN, size = arrowSize, textalign = text.align_center) if i == 0 and onArrowDownInput == true //alert alert("Down arrow") if caution != 0 and cautionInput == true label.new(bar_index - (i), reboundD, color = colorUP, style = label.style_xcross, size = size.tiny, textcolor = na) if reboundU != 0 txtUp = showBuySellText ? "▲₩n" + buyText : "▲" label.new(bar_index - (i), reboundU, txtUp, color = na, style = label.style_label_center, textcolor = colorUP, size = arrowSize, textalign = text.align_center) if i == 0 and onArrowUpInput == true //alert alert("UP arrow") if caution != 0 and cautionInput == true label.new(bar_index - (i), reboundU, color = colorDOWN, style = label.style_xcross, size = size.tiny, textcolor = na) //SAVE HISTORY pastTmac := tmac pastTmau := tmau pastTmad := tmad //LOOP IS ONLY FOR HANDICAPPED if barstate.islast != true break //DRAW REAL BANDS plot(last ? tmau_temp : tmau, title = "TMA Up", color = colorBands, linewidth=1, style = plot.style_line, offset = -HalfLength) plot(last ? tmac_temp : tmac, title = "TMA Mid", color = colorBuffer, linewidth=1, style = plot.style_line, offset = -HalfLength) plot(last ? tmad_temp : tmad, title = "TMA Down", color = colorBands, linewidth=1, style = plot.style_line, offset = -HalfLength)
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-08-11 13:44:34

안녕하세요 예스스탁입니다. 선만 표시되게 작성해 드립니다. input : HalfLength(44); input : PriceType(7);#1: Close, 2:Open, 3:High, 4:Low, 5:Median, 6:Typical, 7:Weighted, 8:Average input : AtrPeriod(120); input : AtrMultiplier(2); input : TMAangle(4); input : crossUpInput(false); input : crossDownInput(false); input : comingBackInput(false); input : onArrowDownInput(false); input : onArrowUpInput(false); input : colorDOWN(red); input : colorUP(green); input : colorBands(Gray); input : cautionInput(true); Array : TX1[100](0),TX2[100](0),TX3[100](0); var : cnt(0),price(0),colorBuffer(Nan); var : asum(0),ATR(0),i(0),j(0); var : sum(0),sumw(0),k(0),tmac(0),tmau(0),tmad(0); var : pastTmac(nan),pastTmau(nan),pastTmad(Nan); var : tmau_temp(nan),tmac_temp(Nan),tmad_temp(nan); var : point(0),reboundD(0),reboundU(0),caution(0),last(False); For cnt = 0 to 99 { Text_Delete(TX1[cnt]); Text_Delete(TX2[cnt]); Text_Delete(TX3[cnt]); } if PriceType == 1 Then Price = close; Else if PriceType == 2 Then Price = open; Else if PriceType == 3 Then Price = high; Else if PriceType == 4 Then Price = low; Else if PriceType == 5 Then Price = (high + low) / 2; Else if PriceType == 6 Then Price = (high + low + close) / 3; Else if PriceType == 7 Then Price = (high + low + close + close) / 4; Else Price = (high + low + close + open)/ 4; //MAIN for i = HalfLength downto 0 { //ATR asum = 0.0; for j = 0 to AtrPeriod - 1 { asum = asum + max(high[i + j + 10], close[i + j + 11]) - min(low[i + j + 10], close[i + j + 11]); } atr = asum/AtrPeriod; //BANDS sum = (HalfLength + 1) * Price[i]; sumw = (HalfLength + 1); k = HalfLength; for j = 1 to HalfLength { sum = sum + k * Price[i + j]; sumw = sumw + k; if (j <= i) Then { sum = sum + k * Price[i - j]; sumw = sumw + k; } k = k -1; } tmac = sum/sumw; tmau = tmac+AtrMultiplier*atr; tmad = tmac-AtrMultiplier*atr; //CHANGE TREND COLOR if pastTmac != 0.0 Then { if tmac > pastTmac Then colorBuffer = colorUP; if tmac < pastTmac then colorBuffer = colorDOWN; } //SIGNALS reboundD = 0.0; reboundU = 0.0; caution = 0.0; if pastTmac != 0.0 Then { if (high[i + 1] > pastTmau and close[i + 1] > open[i + 1] and close[i] < open[i]) Then { reboundD = high[i] + AtrMultiplier * atr / 2; if (tmac - pastTmac > TMAangle * point) Then { caution = reboundD + 10 * point; } } if (low[i + 1] < pastTmad and close[i + 1] < open[i + 1] and close[i] > open[i]) Then { reboundU = low[i] - AtrMultiplier * atr / 2; if (pastTmac - tmac > TMAangle * point) then { caution = reboundU - 10 * point; } } } //LAST REAL if i == HalfLength Then { last = true; tmau_temp = tmau; tmac_temp = tmac; tmad_temp = tmad; } //DRAW HANDICAPPED BANDS if i < HalfLength Then { TX1[i] = Text_New(NextBarSdate[i],NextBarStime[i],Tmau,"-"); Text_SetColor(TX1[i],colorBands); Text_SetStyle(TX1[i],2,2); TX2[i] = Text_New(NextBarSdate[i],NextBarStime[i],Tmac,"-"); Text_SetColor(TX2[i],colorBuffer); Text_SetStyle(TX2[i],2,2); TX3[i] = Text_New(NextBarSdate[i],NextBarStime[i],Tmad,"-"); Text_SetColor(TX3[i],colorBands); Text_SetStyle(TX3[i],2,2); } } //DRAW REAL BANDS plot1(iff(last , tmau_temp , tmau), "TMA Up", colorBands); plot2(iff(last , tmac_temp , tmac), "TMA Mid", colorBuffer); plot3(iff(last , tmad_temp , tmad), "TMA Down", colorBands); FixPlotShift(1,-HalfLength); FixPlotShift(2,-HalfLength); FixPlotShift(3,-HalfLength); 즐거운 하루되세요 > as8282 님이 쓴 글입니다. > 제목 : 예스로 부탁합니다. > 트뷰에서 알게된 지표인데 예스 수식으로 부탁합니다. 미리감사드립니다. //version=5 //author: mladen //rebound arrows and TMA angle caution: Ale //rewritten from MQL5 to Pine: Brylator indicator("TMA Centered Bands Indicator", "TMA v1.0 Gaga", overlay = true, max_lines_count = 500, max_labels_count = 500) //INPUTS var GRP1 = "Parameters" HalfLength = input.int(44, "Centered TMA half period", group = GRP1) string PriceType = input.string("Weighted", "Price to use", options = ["Close", "Open", "High", "Low", "Median", "Typical", "Weighted", "Average"], group = GRP1) AtrPeriod = input.int(120, "Average true range period", group = GRP1) AtrMultiplier = input.float(2, "Average true range multiplier", group = GRP1) TMAangle = input.int(4, "Centered TMA angle caution", group = GRP1) // APPEARANCE (เพิ่มตัวเลือกขนาดและข้อความ BUY/SELL) var GRP4 = "Appearance" arrowSizeOpt = input.string("Large", "Arrow size", options = ["Tiny", "Small", "Normal", "Large", "Huge"], group = GRP4) showBuySellText = input.bool(true, "Show BUY/SELL text on arrows", group = GRP4) buyText = input.string("BUY", "Buy text", inline = "txt", group = GRP4) sellText = input.string("SELL", "Sell text", inline = "txt", group = GRP4) // map ขนาด arrowSize = switch arrowSizeOpt "Tiny" => size.tiny "Small" => size.small "Normal" => size.normal "Large" => size.large => size.huge //VARIABLES float tmac = na float tmau = na float tmad = na var float pastTmac = na //from the previous candle var float pastTmau = na var float pastTmad = na float tmau_temp = na //before looping float tmac_temp = na float tmad_temp = na float point = syminfo.pointvalue //NEEDS MORE TESTS bool last = false //checks if a loop is needed var string alertSignal = "EMPTY" //needed for alarms to avoid repetition //COLORS var GRP2 = "Colors" var color colorBuffer = na color colorDOWN = input.color(color.new(color.red, 0), "Bear", inline = "5", group = GRP2) color colorUP = input.color(color.new(color.green, 0), "Bull", inline = "5", group = GRP2) color colorBands = input.color(color.new(#b2b5be, 0), "Bands", inline = "5", group = GRP2) bool cautionInput = input.bool(true, "Caution label", inline = "6", group = GRP2) //ALERTS var GRP3 = "Alerts (Needs to create alert manually after every change)" bool crossUpInput = input.bool(false, "Crossing up", inline = "7", group = GRP3) bool crossDownInput = input.bool(false, "Crossing down", inline = "7", group = GRP3) bool comingBackInput = input.bool(false, "Coming back", inline = "7", group = GRP3) bool onArrowDownInput = input.bool(false, "On arrow down", inline = "8", group = GRP3) bool onArrowUpInput = input.bool(false, "On arrow up", inline = "8", group = GRP3) //CLEAR LINES a_allLines = line.all if array.size(a_allLines) > 0 for p = 0 to array.size(a_allLines) - 1 line.delete(array.get(a_allLines, p)) //GET PRICE Price(x) => float price = switch PriceType "Close" => close[x] "Open" => open[x] "High" => high[x] "Low" => low[x] "Median" => (high[x] + low[x]) / 2 "Typical" => (high[x] + low[x] + close[x]) / 3 "Weighted" => (high[x] + low[x] + close[x] + close[x]) / 4 "Average" => (high[x] + low[x] + close[x] + open[x])/ 4 price //MAIN for i = HalfLength to 0 //ATR atr = 0.0 for j = 0 to AtrPeriod - 1 atr += math.max(high[i + j + 10], close[i + j + 11]) - math.min(low[i + j + 10], close[i + j + 11]) atr /= AtrPeriod //BANDS sum = (HalfLength + 1) * Price(i) sumw = (HalfLength + 1) k = HalfLength for j = 1 to HalfLength sum += k * Price(i + j) sumw += k if (j <= i) sum += k * Price(i - j) sumw += k k -= 1 tmac := sum/sumw tmau := tmac+AtrMultiplier*atr tmad := tmac-AtrMultiplier*atr //ALERTS if i == 0 //Only on a real candle if (high > tmau and alertSignal != "UP") //crossing up band if crossUpInput == true //checks if activated alert("Crossing up Band") //calling alert alertSignal := "UP" //to avoid repeating else if (low < tmad and alertSignal != "DOWN") //crossing down band if crossDownInput == true alert("Crossing down Band") alertSignal := "DOWN" else if (alertSignal == "DOWN" and high >= tmad and alertSignal != "EMPTY") //back from the down band if comingBackInput == true alert("Coming back") alertSignal := "EMPTY" else if (alertSignal == "UP" and low <= tmau and alertSignal != "EMPTY") //back from the up band if comingBackInput == true alert("Coming back") alertSignal := "EMPTY" //CHANGE TREND COLOR if pastTmac != 0.0 if tmac > pastTmac colorBuffer := colorUP if tmac < pastTmac colorBuffer := colorDOWN //SIGNALS reboundD = 0.0 reboundU = 0.0 caution = 0.0 if pastTmac != 0.0 if (high[i + 1] > pastTmau and close[i + 1] > open[i + 1] and close < open) reboundD := high + AtrMultiplier * atr / 2 if (tmac - pastTmac > TMAangle * point) caution := reboundD + 10 * point if (low[i + 1] < pastTmad and close[i + 1] < open[i + 1] and close > open) reboundU := low - AtrMultiplier * atr / 2 if (pastTmac - tmac > TMAangle * point) caution := reboundU - 10 * point //LAST REAL if barstate.islast and i == HalfLength last := true tmau_temp := tmau tmac_temp := tmac tmad_temp := tmad //DRAW HANDICAPPED BANDS if barstate.islast and i < HalfLength line.new(bar_index - (i + 1), pastTmau, bar_index - (i), tmau, width = 2, style = line.style_dotted, color = colorBands) line.new(bar_index - (i + 1), pastTmac, bar_index - (i), tmac, width = 2, style = line.style_dotted, color = colorBuffer) line.new(bar_index - (i + 1), pastTmad, bar_index - (i), tmad, width = 2, style = line.style_dotted, color = colorBands) //DRAW SIGNALS (ลูกศรใหญ่ขึ้น + มีคำว่า SELL/BUY) if reboundD != 0 txtDown = showBuySellText ? "▼₩n" + sellText : "▼" label.new(bar_index - (i), reboundD, txtDown, color = na, style = label.style_label_center, textcolor = colorDOWN, size = arrowSize, textalign = text.align_center) if i == 0 and onArrowDownInput == true //alert alert("Down arrow") if caution != 0 and cautionInput == true label.new(bar_index - (i), reboundD, color = colorUP, style = label.style_xcross, size = size.tiny, textcolor = na) if reboundU != 0 txtUp = showBuySellText ? "▲₩n" + buyText : "▲" label.new(bar_index - (i), reboundU, txtUp, color = na, style = label.style_label_center, textcolor = colorUP, size = arrowSize, textalign = text.align_center) if i == 0 and onArrowUpInput == true //alert alert("UP arrow") if caution != 0 and cautionInput == true label.new(bar_index - (i), reboundU, color = colorDOWN, style = label.style_xcross, size = size.tiny, textcolor = na) //SAVE HISTORY pastTmac := tmac pastTmau := tmau pastTmad := tmad //LOOP IS ONLY FOR HANDICAPPED if barstate.islast != true break //DRAW REAL BANDS plot(last ? tmau_temp : tmau, title = "TMA Up", color = colorBands, linewidth=1, style = plot.style_line, offset = -HalfLength) plot(last ? tmac_temp : tmac, title = "TMA Mid", color = colorBuffer, linewidth=1, style = plot.style_line, offset = -HalfLength) plot(last ? tmad_temp : tmad, title = "TMA Down", color = colorBands, linewidth=1, style = plot.style_line, offset = -HalfLength)