커뮤니티

변환부탁드려요.

프로필 이미지
주식남
2025-06-16 15:36:37
263
글번호 191775
답변완료
안녕하세요? 파인스크립트를 예스랭귀지로 변환해 보았는데, 에러는 안납니다. 그런데, 너무 부하가 걸리는지 죽어버립니다. 파인스크립트에 맞게 최대한 수정바라겠습니다. == My 변환 == // ▒▒▒▒ 외부 입력 변수 ▒▒▒▒ Input : lengthAlma(8), smooth(1), offset(0.85), sigmaAlma(7), lengthRsi(14), lengthChande(9), glength(9), sigmaGama(1.8), ls_length(20), signalGap(5), level3Color(RGB(56,56,56)), level3Width(1), level7Color(RGB(56,56,56)), level7Width(1); // ▒▒▒▒ 배열 선언 ▒▒▒▒ Array : level[11](0); // 레벨 0~10 구간 가격 Array : tlID[11](0) ; // 레벨별 수평선 오브젝트ID // ▒▒▒▒ 내부 변수 선언 ▒▒▒▒ Var : avpchange(0.0), rsi(0.0), rsiL(false), rsiS(false); Var : chandeMO(0.0), cL(false), cS(false); Var : gma(0.0), sumOfWeights(0.0), weight(0.0), value(0.0); Var : lastSignalBar(0), curBar(0), uptrend(false), dntrend(false); Var : momm(0.0), m1(0.0), m2(0.0), sm1(0.0), sm2(0.0); Var : strength(0), clamped_strength(0); Var : lower_band(0.0), upper_band(0.0), levelStep(0.0), price(0.0); Var : i(0); // ▒▒▒▒ lastSignalBar: na 대체 패턴(최초 바에서 -9999로 초기화) ▒▒▒▒ If BarIndex == 0 Then { lastSignalBar = -9999; } If C != 0 Then { avpchange = Avg((C - C[smooth]) / C * 100, lengthAlma); } rsi = RSI(lengthRsi); If rsi > rsi[1] Then { rsiL = True; } Else { rsiL = False; } If rsi < rsi[1] Then { rsiS = True; } Else { rsiS = False; } momm = C - C[1]; If momm >= 0 Then { m1 = momm; } Else { m1 = 0; } If momm < 0 Then { m2 = -momm; } Else { m2 = 0; } sm1 = 0; sm2 = 0; For i = 0 To lengthChande - 1 { If (C[i] - C[i+1]) >= 0 Then { sm1 = sm1 + (C[i] - C[i+1]); } Else { sm2 = sm2 + (C[i+1] - C[i]); } } If (sm1 + sm2) != 0 Then { chandeMO = 100 * (sm1 - sm2) / (sm1 + sm2); } Else { chandeMO = 0; } If chandeMO > chandeMO[1] Then { cL = True; } Else { cL = False; } If chandeMO < chandeMO[1] Then { cS = True; } Else { cS = False; } gma = 0; sumOfWeights = 0; For i = 0 To glength - 1 { weight = Exp(-Power(((i - (glength - 1)) / (2 * sigmaGama)), 2) / 2); value = Highest(avpchange, i+1) + Lowest(avpchange, i+1); gma = gma + (value * weight); sumOfWeights = sumOfWeights + weight; } If sumOfWeights != 0 Then { gma = (gma / sumOfWeights) / 2; } gma = EMA(gma, 7); If C > Avg(C, 50) Then { uptrend = True; } Else { uptrend = False; } If C < Avg(C, 50) Then { dntrend = True; } Else { dntrend = False; } lower_band = Lowest(L, ls_length); upper_band = Highest(H, ls_length); levelStep = (upper_band - lower_band) / 10; For i = 0 To 10 { level[i] = lower_band + levelStep * i; } strength = 0; For i = 0 To 10 { If CrossUp(C, level[i]) Then { strength = strength + 1; } If CrossDown(C, level[i])Then { strength = strength - 1; } } If strength < 0 Then { clamped_strength = 0; } Else If strength > 10 Then { clamped_strength = 10; } Else { clamped_strength = strength; } price = level[clamped_strength]; curBar = BarIndex; If CrossUp(avpchange, gma) and rsiL and cL and uptrend and (lastSignalBar < 0 or curBar - lastSignalBar > signalGap) Then { text_new(sDate, sTime, L - 2*PriceScale, "Long ▲"); lastSignalBar = curBar; } If CrossDown(avpchange, gma) and rsiS and cS and dntrend and (lastSignalBar < 0 or curBar - lastSignalBar > signalGap) Then { text_new(sDate, sTime, H + 2*PriceScale, "Short ▼"); lastSignalBar = curBar; } For i = 0 To 10 { If tlID[i] != 0 Then { TL_Delete(tlID[i]); } tlID[i] = TL_New(sDate[1], sTime[1], level[i], sDate, sTime, level[i]); If i = 3 Then { TL_SetColor(tlID[i], level3Color); TL_SetSize(tlID[i], level3Width); } Else If i = 7 Then { TL_SetColor(tlID[i], level7Color); TL_SetSize(tlID[i], level7Width); } Else { TL_SetColor(tlID[i], RGB(200,200,200)); TL_SetSize(tlID[i], 1); } } == 파인스크립트 원본 == indicator("전략", overlay=true, max_lines_count=500, max_labels_count=500) // === 3, 7 levels highlightColor3 = input.color(color.rgb(56, 56, 56), "Level 3 강조 색상") highlightWidth3 = input.int(1, "Level 3 선 두께", minval=1, maxval=5) highlightTransp3 = input.int(0, "Level 3 투명도", minval=0, maxval=100) highlightColor7 = input.color(color.rgb(56, 56, 56), "Level 7 강조 색상") highlightWidth7 = input.int(1, "Level 7 선 두께", minval=1, maxval=5) highlightTransp7 = input.int(0, "Level 7 투명도", minval=0, maxval=100) // === ALMA Smoothing src = input(close, title='Source', group = "ALMA Smoothing") smooth = input.int(1, title='Smoothing', minval=1, group = "ALMA Smoothing") length1 = input.int(8, title='Lookback', minval=1, group = "ALMA Smoothing") offset = 0.85 sigma1 = 7 pchange = ta.change(src, smooth) / src * 100 avpchange = ta.alma(pchange, length1, offset, sigma1) // === RSI & Chande rsi = ta.rsi(close, 14) rsiL = rsi > rsi[1] rsiS = rsi < rsi[1] length11 = 9 momm = ta.change(close) m1 = momm >= 0 ? momm : 0 m2 = momm < 0 ? -momm : 0 sm1 = math.sum(m1, length11) sm2 = math.sum(m2, length11) chandeMO = 100 * (sm1 - sm2) / (sm1 + sm2) cL = chandeMO > chandeMO[1] cS = chandeMO < chandeMO[1] // === GAMA glength = input.int(9, minval=1, title="GAMA Length", group = "Gaussian Adaptive Moving Average") sigma = input.float(1.8, minval=0.1, title="Standard Deviation", group = "Gaussian Adaptive Moving Average") var float gma = na var float sumOfWeights = na gma := 0.0 sumOfWeights := 0.0 for i = 0 to glength - 1 weight = math.exp(-math.pow(((i - (glength - 1)) / (2 * sigma)), 2) / 2) value = ta.highest(avpchange, i + 1) + ta.lowest(avpchange, i + 1) gma += (value * weight) sumOfWeights += weight gma := ta.ema((gma / sumOfWeights) / 2, 7) // === Color Theme colorTheme = input.string("Navy-Copper", title="Color Theme", options=["Cyan-Magenta", "Blue-Gold", "Indigo-Champagne", "Teal-Ruby", "Navy-Copper", "Teal-Gold"]) up_color = colorTheme == "Cyan-Magenta" ? color.rgb(10, 216, 182) : colorTheme == "Blue-Gold" ? color.rgb(30, 144, 255) : colorTheme == "Indigo-Champagne" ? color.rgb(128, 0, 128) : colorTheme == "Teal-Ruby" ? color.rgb(0, 160, 150) : colorTheme == "Navy-Copper" ? color.rgb(15, 76, 129) : colorTheme == "Teal-Gold" ? color.rgb(93, 158, 154) : color.rgb(255, 255, 255) // fallback dn_color = colorTheme == "Cyan-Magenta" ? color.rgb(212, 41, 184) : colorTheme == "Blue-Gold" ? color.rgb(255, 140, 0) : colorTheme == "Indigo-Champagne" ? color.rgb(218, 165, 32) : colorTheme == "Teal-Ruby" ? color.rgb(190, 30, 60) : colorTheme == "Navy-Copper" ? color.rgb(140, 74, 47) : colorTheme == "Teal-Gold" ? color.rgb(166, 124, 82) : color.rgb(255, 255, 255) // fallback // === Signal Labels var int lastSignalBar = na signalGap = 5 inUptrend = close > ta.sma(close, 50) inDntrend = close < ta.sma(close, 50) if ta.crossover(avpchange, gma) and rsiL and cL and inUptrend and (na(lastSignalBar) or bar_index - lastSignalBar > signalGap) label.new(bar_index, low, text="Long ▲", style=label.style_label_up, color=color.rgb(0, 161, 5), textcolor=color.white, size=size.normal) lastSignalBar := bar_index if ta.crossunder(avpchange, gma) and rsiS and cS and inDntrend and (na(lastSignalBar) or bar_index - lastSignalBar > signalGap) label.new(bar_index, high, text="Short ▼", style=label.style_label_down, color=color.rgb(215, 0, 0), textcolor=color.white, size=size.normal) lastSignalBar := bar_index alertcondition(ta.crossover(avpchange, gma) and rsiL and cL and inUptrend, title="Buy Signal", message="Go Long! {{exchange}}:{{ticker}}") alertcondition(ta.crossunder(avpchange, gma) and rsiS and cS and inDntrend, title="Sell Signal", message="Go Short! {{exchange}}:{{ticker}}") // === LEVELS STRENGTH INDEX int ls_length = input.int(20, 'Levels Length') int transp = input.int(5, 'Levels Transparency', minval = 2, maxval = 10) var float[] level = array.new_float(11, 0.0) var int strength = 0 float lower_band = ta.lowest(ls_length) float upper_band = ta.highest(ls_length) float step = (upper_band - lower_band) / 10 for i = 0 to 10 array.set(level, i, lower_band + step * i) float lvl = array.get(level, i) if ta.crossover(close, lvl) strength := strength + 1 if ta.crossunder(close, lvl) strength := strength - 1 clamped_strength = strength < 0 ? 0 : strength > 10 ? 10 : strength float price = barstate.islast ? array.get(level, clamped_strength) : close color[] colors = array.new_color(11) for i = 0 to 10 float lvl = array.get(level, i) color c = close > lvl ? color.new(up_color, 100 - transp * (i + 1)) : color.new(dn_color, 100 - transp * (11 - i)) array.set(colors, i, c) // === Plot Levels plot0 = plot(array.get(level, 0), color=array.get(colors, 0), display=display.all, title="Level 0") plot1 = plot(array.get(level, 1), color=array.get(colors, 1), display=display.all, title="Level 1") plot2 = plot(array.get(level, 2), color=array.get(colors, 2), display=display.all, title="Level 2") plot3 = plot(array.get(level, 3), color=array.get(colors, 3), display=display.all, title="Level 3") plot4 = plot(array.get(level, 4), color=array.get(colors, 4), display=display.all, title="Level 4") plot5 = plot(array.get(level, 5), color=array.get(colors, 5), display=display.all, title="Level 5") plot6 = plot(array.get(level, 6), color=array.get(colors, 6), display=display.all, title="Level 6") plot7 = plot(array.get(level, 7), color=array.get(colors, 7), display=display.all, title="Level 7") plot8 = plot(array.get(level, 8), color=array.get(colors, 8), display=display.all, title="Level 8") plot9 = plot(array.get(level, 9), color=array.get(colors, 9), display=display.all, title="Level 9") plot10 = plot(array.get(level, 10), color=array.get(colors, 10), display=display.all, title="Level 10") // === Intense plot(array.get(level, 3), title="Level 3 Highlight", color=color.new(highlightColor3, highlightTransp3), linewidth=highlightWidth3) plot(array.get(level, 7), title="Level 7 Highlight", color=color.new(highlightColor7, highlightTransp7), linewidth=highlightWidth7) // === Fill fill(plot0, plot1, color=array.get(colors, 1)) fill(plot1, plot2, color=array.get(colors, 1)) fill(plot2, plot3, color=array.get(colors, 2)) fill(plot3, plot4, color=array.get(colors, 3)) fill(plot4, plot5, color=array.get(colors, 4)) fill(plot5, plot6, color=array.get(colors, 5)) fill(plot6, plot7, color=array.get(colors, 6)) fill(plot7, plot8, color=array.get(colors, 7)) fill(plot8, plot9, color=array.get(colors, 8)) fill(plot9, plot10, color=array.get(colors, 9))
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-06-17 09:23:17

안녕하세요 예스스탁입니다. // === ALMA Smoothing input : smooth(1); input : length1(8); input : offset(0.85); input : sigma1(7); var : pchange(0),avpchange(0); var : mm(0),ss(0),norm(0),sum(0),i(0),weight(0); pchange = (close-close[smooth]) / close * 100; mm = offset * (length1 - 1); ss = length1 / sigma1; norm = 0.0; sum = 0.0; for i = 0 to length1 - 1 { weight = exp(-1 * pow(i - mm, 2) / (2 * pow(ss, 2))); norm = norm + weight; sum = sum + pchange[length1 - i - 1] * weight; } avpchange = sum / norm; var : rsiv(0),rsil(False),rsis(False); // === RSI & Chande rsiv = rsi(14); rsiL = rsiv > rsiv[1]; rsiS = rsiv < rsiv[1]; input : length11(9); var : momm(0),m1(0),m2(0),sm1(0),sm2(0),chandeMO(0),cl(False),cs(False); momm = close-close[1]; m1 = iff(momm >= 0 , momm , 0); m2 = iff(momm < 0 , -momm , 0); sm1 = AccumN(m1, length11); sm2 = AccumN(m2, length11); chandeMO = 100 * (sm1 - sm2) / (sm1 + sm2); cL = chandeMO > chandeMO[1]; cS = chandeMO < chandeMO[1]; // === GAMA input : glength(9); input : sigma(1.8); var : gma(Nan),sumOfWeights(Nan),value(0); gma = 0.0; sumOfWeights = 0.0; for i = 0 to glength - 1 { weight =exp(-pow(((i - (glength - 1)) / (2 * sigma)), 2) / 2); value = highest(avpchange, i + 1) + lowest(avpchange, i + 1); gma = gma + (value * weight); sumOfWeights = sumOfWeights+weight; } gma = ema((gma / sumOfWeights) / 2, 7); var : up_color(0),dn_color(0); up_color = Red; dn_color = Blue; var : lastSignalBar(Nan); var : signalGap(0),inUptrend(False),inDntrend(False),tx(0); signalGap = 5; inUptrend = close > ma(close, 50); inDntrend = close < ma(close, 50); if crossup(avpchange, gma) and rsiL and cL and inUptrend and (IsNan(lastSignalBar) == true or index - lastSignalBar > signalGap) Then { tx = text_new(sDate,sTime,low,"Long▲"); Text_SetColor(tx,rgb(0, 161, 5)); Text_SetStyle(tx,2,0); lastSignalBar = index; } if CrossDown(avpchange, gma) and rsiS and cS and inDntrend and (IsNan(lastSignalBar) == true or index - lastSignalBar > signalGap) Then { tx = text_new(sdate,stime,high,"Short▼"); Text_SetColor(tx,rgb(215, 0, 0)); Text_SetStyle(tx,2,1); lastSignalBar = index; } // === LEVELS STRENGTH INDEX input : ls_length(20); input : transp(5); Array : level[11](0),colors[11](0); var : strength(0),lower_band(0),upper_band(0),stp(0),lvl(0); lower_band = lowest(L,ls_length); upper_band = highest(H,ls_length); stp = (upper_band - lower_band) / 10; for i = 0 to 10 { Level[i] = lower_band + stp * i; lvl = level[i]; if close> lvl and close[1] < lvl Then strength = strength + 1; if close < lvl and close[1] < lvl Then strength = strength - 1; } var : clamped_strength(0),price(0); clamped_strength = iff(strength < 0 , 0 , iff(strength > 10 , 10 , strength)); price = level[clamped_strength]; for i = 0 to 10 { lvl = level[i]; colors[i] = iff(close > lvl , up_color,dn_color); } // === Plot Levels plot1(level[0],"Level 0",colors[0]); plot2(level[1],"Level 1",colors[1]); plot3(level[2],"Level 2",colors[2]); plot4(level[3],"Level 3",rgb(56, 56, 56),def,3); plot5(level[4],"Level 4",colors[4]); plot6(level[5],"Level 5",colors[5]); plot7(level[6],"Level 6",colors[6]); plot8(level[7],"Level 7",rgb(56, 56, 56),Def,7); plot9(level[8],"Level 8",colors[8]); plot10(level[9],"Level 9",colors[9]); plot11(level[10],"Level 10",colors[10]); 즐거운 하루되세요 > 주식남 님이 쓴 글입니다. > 제목 : 변환부탁드려요. > 안녕하세요? 파인스크립트를 예스랭귀지로 변환해 보았는데, 에러는 안납니다. 그런데, 너무 부하가 걸리는지 죽어버립니다. 파인스크립트에 맞게 최대한 수정바라겠습니다. == My 변환 == // ▒▒▒▒ 외부 입력 변수 ▒▒▒▒ Input : lengthAlma(8), smooth(1), offset(0.85), sigmaAlma(7), lengthRsi(14), lengthChande(9), glength(9), sigmaGama(1.8), ls_length(20), signalGap(5), level3Color(RGB(56,56,56)), level3Width(1), level7Color(RGB(56,56,56)), level7Width(1); // ▒▒▒▒ 배열 선언 ▒▒▒▒ Array : level[11](0); // 레벨 0~10 구간 가격 Array : tlID[11](0) ; // 레벨별 수평선 오브젝트ID // ▒▒▒▒ 내부 변수 선언 ▒▒▒▒ Var : avpchange(0.0), rsi(0.0), rsiL(false), rsiS(false); Var : chandeMO(0.0), cL(false), cS(false); Var : gma(0.0), sumOfWeights(0.0), weight(0.0), value(0.0); Var : lastSignalBar(0), curBar(0), uptrend(false), dntrend(false); Var : momm(0.0), m1(0.0), m2(0.0), sm1(0.0), sm2(0.0); Var : strength(0), clamped_strength(0); Var : lower_band(0.0), upper_band(0.0), levelStep(0.0), price(0.0); Var : i(0); // ▒▒▒▒ lastSignalBar: na 대체 패턴(최초 바에서 -9999로 초기화) ▒▒▒▒ If BarIndex == 0 Then { lastSignalBar = -9999; } If C != 0 Then { avpchange = Avg((C - C[smooth]) / C * 100, lengthAlma); } rsi = RSI(lengthRsi); If rsi > rsi[1] Then { rsiL = True; } Else { rsiL = False; } If rsi < rsi[1] Then { rsiS = True; } Else { rsiS = False; } momm = C - C[1]; If momm >= 0 Then { m1 = momm; } Else { m1 = 0; } If momm < 0 Then { m2 = -momm; } Else { m2 = 0; } sm1 = 0; sm2 = 0; For i = 0 To lengthChande - 1 { If (C[i] - C[i+1]) >= 0 Then { sm1 = sm1 + (C[i] - C[i+1]); } Else { sm2 = sm2 + (C[i+1] - C[i]); } } If (sm1 + sm2) != 0 Then { chandeMO = 100 * (sm1 - sm2) / (sm1 + sm2); } Else { chandeMO = 0; } If chandeMO > chandeMO[1] Then { cL = True; } Else { cL = False; } If chandeMO < chandeMO[1] Then { cS = True; } Else { cS = False; } gma = 0; sumOfWeights = 0; For i = 0 To glength - 1 { weight = Exp(-Power(((i - (glength - 1)) / (2 * sigmaGama)), 2) / 2); value = Highest(avpchange, i+1) + Lowest(avpchange, i+1); gma = gma + (value * weight); sumOfWeights = sumOfWeights + weight; } If sumOfWeights != 0 Then { gma = (gma / sumOfWeights) / 2; } gma = EMA(gma, 7); If C > Avg(C, 50) Then { uptrend = True; } Else { uptrend = False; } If C < Avg(C, 50) Then { dntrend = True; } Else { dntrend = False; } lower_band = Lowest(L, ls_length); upper_band = Highest(H, ls_length); levelStep = (upper_band - lower_band) / 10; For i = 0 To 10 { level[i] = lower_band + levelStep * i; } strength = 0; For i = 0 To 10 { If CrossUp(C, level[i]) Then { strength = strength + 1; } If CrossDown(C, level[i])Then { strength = strength - 1; } } If strength < 0 Then { clamped_strength = 0; } Else If strength > 10 Then { clamped_strength = 10; } Else { clamped_strength = strength; } price = level[clamped_strength]; curBar = BarIndex; If CrossUp(avpchange, gma) and rsiL and cL and uptrend and (lastSignalBar < 0 or curBar - lastSignalBar > signalGap) Then { text_new(sDate, sTime, L - 2*PriceScale, "Long ▲"); lastSignalBar = curBar; } If CrossDown(avpchange, gma) and rsiS and cS and dntrend and (lastSignalBar < 0 or curBar - lastSignalBar > signalGap) Then { text_new(sDate, sTime, H + 2*PriceScale, "Short ▼"); lastSignalBar = curBar; } For i = 0 To 10 { If tlID[i] != 0 Then { TL_Delete(tlID[i]); } tlID[i] = TL_New(sDate[1], sTime[1], level[i], sDate, sTime, level[i]); If i = 3 Then { TL_SetColor(tlID[i], level3Color); TL_SetSize(tlID[i], level3Width); } Else If i = 7 Then { TL_SetColor(tlID[i], level7Color); TL_SetSize(tlID[i], level7Width); } Else { TL_SetColor(tlID[i], RGB(200,200,200)); TL_SetSize(tlID[i], 1); } } == 파인스크립트 원본 == indicator("전략", overlay=true, max_lines_count=500, max_labels_count=500) // === 3, 7 levels highlightColor3 = input.color(color.rgb(56, 56, 56), "Level 3 강조 색상") highlightWidth3 = input.int(1, "Level 3 선 두께", minval=1, maxval=5) highlightTransp3 = input.int(0, "Level 3 투명도", minval=0, maxval=100) highlightColor7 = input.color(color.rgb(56, 56, 56), "Level 7 강조 색상") highlightWidth7 = input.int(1, "Level 7 선 두께", minval=1, maxval=5) highlightTransp7 = input.int(0, "Level 7 투명도", minval=0, maxval=100) // === ALMA Smoothing src = input(close, title='Source', group = "ALMA Smoothing") smooth = input.int(1, title='Smoothing', minval=1, group = "ALMA Smoothing") length1 = input.int(8, title='Lookback', minval=1, group = "ALMA Smoothing") offset = 0.85 sigma1 = 7 pchange = ta.change(src, smooth) / src * 100 avpchange = ta.alma(pchange, length1, offset, sigma1) // === RSI & Chande rsi = ta.rsi(close, 14) rsiL = rsi > rsi[1] rsiS = rsi < rsi[1] length11 = 9 momm = ta.change(close) m1 = momm >= 0 ? momm : 0 m2 = momm < 0 ? -momm : 0 sm1 = math.sum(m1, length11) sm2 = math.sum(m2, length11) chandeMO = 100 * (sm1 - sm2) / (sm1 + sm2) cL = chandeMO > chandeMO[1] cS = chandeMO < chandeMO[1] // === GAMA glength = input.int(9, minval=1, title="GAMA Length", group = "Gaussian Adaptive Moving Average") sigma = input.float(1.8, minval=0.1, title="Standard Deviation", group = "Gaussian Adaptive Moving Average") var float gma = na var float sumOfWeights = na gma := 0.0 sumOfWeights := 0.0 for i = 0 to glength - 1 weight = math.exp(-math.pow(((i - (glength - 1)) / (2 * sigma)), 2) / 2) value = ta.highest(avpchange, i + 1) + ta.lowest(avpchange, i + 1) gma += (value * weight) sumOfWeights += weight gma := ta.ema((gma / sumOfWeights) / 2, 7) // === Color Theme colorTheme = input.string("Navy-Copper", title="Color Theme", options=["Cyan-Magenta", "Blue-Gold", "Indigo-Champagne", "Teal-Ruby", "Navy-Copper", "Teal-Gold"]) up_color = colorTheme == "Cyan-Magenta" ? color.rgb(10, 216, 182) : colorTheme == "Blue-Gold" ? color.rgb(30, 144, 255) : colorTheme == "Indigo-Champagne" ? color.rgb(128, 0, 128) : colorTheme == "Teal-Ruby" ? color.rgb(0, 160, 150) : colorTheme == "Navy-Copper" ? color.rgb(15, 76, 129) : colorTheme == "Teal-Gold" ? color.rgb(93, 158, 154) : color.rgb(255, 255, 255) // fallback dn_color = colorTheme == "Cyan-Magenta" ? color.rgb(212, 41, 184) : colorTheme == "Blue-Gold" ? color.rgb(255, 140, 0) : colorTheme == "Indigo-Champagne" ? color.rgb(218, 165, 32) : colorTheme == "Teal-Ruby" ? color.rgb(190, 30, 60) : colorTheme == "Navy-Copper" ? color.rgb(140, 74, 47) : colorTheme == "Teal-Gold" ? color.rgb(166, 124, 82) : color.rgb(255, 255, 255) // fallback // === Signal Labels var int lastSignalBar = na signalGap = 5 inUptrend = close > ta.sma(close, 50) inDntrend = close < ta.sma(close, 50) if ta.crossover(avpchange, gma) and rsiL and cL and inUptrend and (na(lastSignalBar) or bar_index - lastSignalBar > signalGap) label.new(bar_index, low, text="Long ▲", style=label.style_label_up, color=color.rgb(0, 161, 5), textcolor=color.white, size=size.normal) lastSignalBar := bar_index if ta.crossunder(avpchange, gma) and rsiS and cS and inDntrend and (na(lastSignalBar) or bar_index - lastSignalBar > signalGap) label.new(bar_index, high, text="Short ▼", style=label.style_label_down, color=color.rgb(215, 0, 0), textcolor=color.white, size=size.normal) lastSignalBar := bar_index alertcondition(ta.crossover(avpchange, gma) and rsiL and cL and inUptrend, title="Buy Signal", message="Go Long! {{exchange}}:{{ticker}}") alertcondition(ta.crossunder(avpchange, gma) and rsiS and cS and inDntrend, title="Sell Signal", message="Go Short! {{exchange}}:{{ticker}}") // === LEVELS STRENGTH INDEX int ls_length = input.int(20, 'Levels Length') int transp = input.int(5, 'Levels Transparency', minval = 2, maxval = 10) var float[] level = array.new_float(11, 0.0) var int strength = 0 float lower_band = ta.lowest(ls_length) float upper_band = ta.highest(ls_length) float step = (upper_band - lower_band) / 10 for i = 0 to 10 array.set(level, i, lower_band + step * i) float lvl = array.get(level, i) if ta.crossover(close, lvl) strength := strength + 1 if ta.crossunder(close, lvl) strength := strength - 1 clamped_strength = strength < 0 ? 0 : strength > 10 ? 10 : strength float price = barstate.islast ? array.get(level, clamped_strength) : close color[] colors = array.new_color(11) for i = 0 to 10 float lvl = array.get(level, i) color c = close > lvl ? color.new(up_color, 100 - transp * (i + 1)) : color.new(dn_color, 100 - transp * (11 - i)) array.set(colors, i, c) // === Plot Levels plot0 = plot(array.get(level, 0), color=array.get(colors, 0), display=display.all, title="Level 0") plot1 = plot(array.get(level, 1), color=array.get(colors, 1), display=display.all, title="Level 1") plot2 = plot(array.get(level, 2), color=array.get(colors, 2), display=display.all, title="Level 2") plot3 = plot(array.get(level, 3), color=array.get(colors, 3), display=display.all, title="Level 3") plot4 = plot(array.get(level, 4), color=array.get(colors, 4), display=display.all, title="Level 4") plot5 = plot(array.get(level, 5), color=array.get(colors, 5), display=display.all, title="Level 5") plot6 = plot(array.get(level, 6), color=array.get(colors, 6), display=display.all, title="Level 6") plot7 = plot(array.get(level, 7), color=array.get(colors, 7), display=display.all, title="Level 7") plot8 = plot(array.get(level, 8), color=array.get(colors, 8), display=display.all, title="Level 8") plot9 = plot(array.get(level, 9), color=array.get(colors, 9), display=display.all, title="Level 9") plot10 = plot(array.get(level, 10), color=array.get(colors, 10), display=display.all, title="Level 10") // === Intense plot(array.get(level, 3), title="Level 3 Highlight", color=color.new(highlightColor3, highlightTransp3), linewidth=highlightWidth3) plot(array.get(level, 7), title="Level 7 Highlight", color=color.new(highlightColor7, highlightTransp7), linewidth=highlightWidth7) // === Fill fill(plot0, plot1, color=array.get(colors, 1)) fill(plot1, plot2, color=array.get(colors, 1)) fill(plot2, plot3, color=array.get(colors, 2)) fill(plot3, plot4, color=array.get(colors, 3)) fill(plot4, plot5, color=array.get(colors, 4)) fill(plot5, plot6, color=array.get(colors, 5)) fill(plot6, plot7, color=array.get(colors, 6)) fill(plot7, plot8, color=array.get(colors, 7)) fill(plot8, plot9, color=array.get(colors, 8)) fill(plot9, plot10, color=array.get(colors, 9))