답변완료
지표 부탁 드립니다
//@version=5indicator("7/19 EMA Crossover Alerts", overlay=true)// ==================== INPUTS ====================fastLen = input.int(7, "Fast EMA")slowLen = input.int(19, "Slow EMA")slCandles = input.int(4, "SL Candles Lookback", options=[3, 4])skipSaturday = input.bool(true, "Skip Saturday")showSLLevels = input.bool(true, "Show SL Levels on Signal")// ==================== EMAs ====================ema7 = ta.ema(close, fastLen)ema19 = ta.ema(close, slowLen)// ==================== SIGNALS ====================bullishCross = ta.crossover(ema7, ema19)bearishCross = ta.crossunder(ema7, ema19)// ==================== DAY FILTER ====================canTrade = skipSaturday ? dayofweek != dayofweek.saturday : true// ==================== STOP LOSS CALCULATIONS ====================lowestLow3 = math.min(low, math.min(low[1], low[2]))lowestLow4 = math.min(low, math.min(low[1], math.min(low[2], low[3])))highestHigh3 = math.max(high, math.max(high[1], high[2]))highestHigh4 = math.max(high, math.max(high[1], math.max(high[2], high[3])))longSL = slCandles == 3 ? lowestLow3 : lowestLow4shortSL = slCandles == 3 ? highestHigh3 : highestHigh4// ==================== ENTRY CONDITIONS ====================longSignal = bullishCross and canTradeshortSignal = bearishCross and canTradeskippedLong = bullishCross and not canTradeskippedShort = bearishCross and not canTrade// ==================== TRACK TREND ====================var int trend = 0if bullishCross trend := 1if bearishCross trend := -1// ==================== PLOTS ====================plot(ema7, "7 EMA", color.lime, 2)plot(ema19, "19 EMA", color.red, 2)// Signal markersplotshape(longSignal, "Long Signal", shape.triangleup, location.belowbar, color.lime, size=size.normal, text="LONG")plotshape(shortSignal, "Short Signal", shape.triangledown, location.abovebar, color.red, size=size.normal, text="SHORT")plotshape(skippedLong, "Skip Long", shape.xcross, location.belowbar, color.gray, size=size.small, text="SKIP")plotshape(skippedShort, "Skip Short", shape.xcross, location.abovebar, color.gray, size=size.small, text="SKIP")// SL level lines on signalsplot(showSLLevels and longSignal ? longSL : na, "Long SL", color.orange, 2, plot.style_circles)plot(showSLLevels and shortSignal ? shortSL : na, "Short SL", color.orange, 2, plot.style_circles)// Backgroundbgcolor(ema7 > ema19 ? color.new(color.green, 93) : color.new(color.red, 93))// ==================== INFO TABLE ====================var table t = table.new(position.top_right, 2, 6, bgcolor=color.new(color.black, 80))if barstate.islast table.cell(t, 0, 0, "7/19 EMA ALERTS", text_color=color.white, bgcolor=color.blue) table.cell(t, 1, 0, "", bgcolor=color.blue) table.cell(t, 0, 1, "Trend:", text_color=color.white, text_size=size.small) table.cell(t, 1, 1, ema7 > ema19 ? "BULLISH" : "BEARISH", text_color=ema7 > ema19 ? color.lime : color.red, text_size=size.small) table.cell(t, 0, 2, "EMA " + str.tostring(fastLen) + ":", text_color=color.white, text_size=size.small) table.cell(t, 1, 2, str.tostring(ema7, "#.##"), text_color=color.lime, text_size=size.small) table.cell(t, 0, 3, "EMA " + str.tostring(slowLen) + ":", text_color=color.white, text_size=size.small) table.cell(t, 1, 3, str.tostring(ema19, "#.##"), text_color=color.red, text_size=size.small) table.cell(t, 0, 4, "Long SL:", text_color=color.white, text_size=size.small) table.cell(t, 1, 4, str.tostring(longSL, "#.##"), text_color=color.orange, text_size=size.small) table.cell(t, 0, 5, "Short SL:", text_color=color.white, text_size=size.small) table.cell(t, 1, 5, str.tostring(shortSL, "#.##"), text_color=color.orange, text_size=size.small)// ==================== ALERTS ====================// Main entry alertsalertcondition(longSignal, "Long Entry", "7/19 EMA: LONG Signal")alertcondition(shortSignal, "Short Entry", "7/19 EMA: SHORT Signal")// Raw crossover alerts (ignore Saturday filter)alertcondition(bullishCross, "Bullish Crossover (Any)", "7/19 EMA: Bullish Crossover")alertcondition(bearishCross, "Bearish Crossover (Any)", "7/19 EMA: Bearish Crossover")// Any signal alert (for single alert setup)alertcondition(longSignal or shortSignal, "Any Signal", "7/19 EMA: Signal Triggered")
2025-12-20
121
글번호 229234
지표
답변완료
지표 부탁 드립니다
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Uncle_the_shooter//@version=6indicator('Pivot Oscillator', overlay=false, max_lines_count=500, max_labels_count=500, precision=2)// PIVOT SETTINGS (user inputs) lenSwing = input.int(5, 'Pivot Length', minval=1, group='Pivot Settings')pivotLevel = input.float(0.5, 'Pivot Level', minval=0.0, maxval=1.0, step=0.01, group='Pivot Settings')lookback = input.int(5, 'Pivot Lookback', minval=1, group='Pivot Settings')// ATR SCALING atrLen = input.int(14, 'ATR Length', minval=1, group='ATR Settings')multUp = input.float(15.0, 'ATR Multiplier Up', minval=0.1, group='ATR Settings')multDown = input.float(15.0, 'ATR Multiplier Down', minval=0.1, group='ATR Settings')// THRESHOLD LEVELS obLevel = input.float(70, 'Overbought Level', minval=51, maxval=99, group='Threshold Levels')osLevel = input.float(30, 'Oversold Level', minval=1, maxval=49, group='Threshold Levels')maOverbought = input.float(60, 'MA Overbought Threshold', minval=51, maxval=99, group='Threshold Levels')maOversold = input.float(40, 'MA Oversold Threshold', minval=1, maxval=49, group='Threshold Levels')// SIGNAL SETTINGS signalLength = input.int(14, 'SMA Length for Signal', group='Signal Settings')extraSmooth = input.int(10, "SMA Smoothing", minval=1, group='Signal Settings')// COLORS bullColor = input.color(color.rgb(22,193,67), 'Bullish Color', group='Style Settings')bearColor = input.color(color.rgb(229,11,11), 'Bearish Color', group='Style Settings')signalColorBull = input.color(color.rgb(22,193,67), 'Signal SMA Bullish', group='Style Settings') signalColorBear = input.color(color.rgb(229,11,11), 'Signal SMA Bearish', group='Style Settings') obColor = input.color(color.red, 'Overbought Line Color', group='Style Settings')osColor = input.color(color.green, 'Oversold Line Color', group='Style Settings')midLineColor = input.color(color.gray, 'Midline 50 Color', group='Style Settings') // <--- nowy inputtextColor = input.color(color.white, 'Text Color', group='Style Settings')// GRADIENT SETTINGSshowOverboughtGradient = input.bool(true, 'Show Overbought Gradient', group='Gradient Settings')showOversoldGradient = input.bool(true, 'Show Oversold Gradient', group='Gradient Settings')showOscillatorGradient = input.bool(true, 'Show Oscillator Gradient', group='Gradient Settings')showMaGradient = input.bool(true, 'Show Moving Average Gradient', group='Gradient Settings')fillEnabled = input.bool(true, 'Enable Gradient Fill', group='Gradient Settings')fillTransparency = input.int(75, 'Gradient Fill Transparency', minval=0, maxval=100, group='Gradient Settings')bandTransparency = input.int(50, 'Band/Label Gradient Transparency', minval=0, maxval=100, group='Gradient Settings')// INTERNAL VARIABLES rangeUpper = 60rangeLower = 5var int gradientTransparency = 85// PIVOTS CALCULATIONph = ta.pivothigh(high, lenSwing, lenSwing)pl = ta.pivotlow(low, lenSwing, lenSwing)var float[] phArray = array.new_float()var float[] plArray = array.new_float()if not na(ph) array.push(phArray, ph) if array.size(phArray) > lookback array.shift(phArray)if not na(pl) array.push(plArray, pl) if array.size(plArray) > lookback array.shift(plArray)avgPH = array.size(phArray) > 0 ? array.avg(phArray) : naavgPL = array.size(plArray) > 0 ? array.avg(plArray) : napivotLine = not na(avgPH) and not na(avgPL) ? avgPL + (avgPH - avgPL) * pivotLevel : naosc_raw = close - nz(pivotLine)// ATR SCALINGatr = ta.atr(atrLen)atr_safe = atr > 0 ? atr : 1upper_bound = atr_safe * multUplower_bound = atr_safe * multDownfloat osc_scaled = 50.0if osc_raw > 0 osc_scaled := 50.0 + 50.0 * (osc_raw / upper_bound)else if osc_raw < 0 osc_scaled := 50.0 + 50.0 * (osc_raw / lower_bound)else osc_scaled := 50.0osc_scaled := math.max(1.0, math.min(100.0, osc_scaled))oscSignal = ta.sma(osc_scaled, signalLength)// DYNAMIC COLORS FOR OB/OS ob_gradient_color = oscSignal >= maOverbought ? obColor : color.grayos_gradient_color = oscSignal <= maOversold ? osColor : color.gray// PLOTTING hline(obLevel, 'Overbought', color=obColor, linestyle=hline.style_dashed, linewidth=1)plot(showOverboughtGradient ? obLevel : na, 'OB Gradient', color=color.new(ob_gradient_color, bandTransparency), linewidth=8, editable=false)hline(osLevel, 'Oversold', color=osColor, linestyle=hline.style_dashed, linewidth=1)plot(showOversoldGradient ? osLevel : na, 'OS Gradient', color=color.new(os_gradient_color, bandTransparency), linewidth=8, editable=false)// MIDLINE 50hline(50, 'Midline 50', color=midLineColor, linestyle=hline.style_dashed, linewidth=1)hline(1, 'Min', color=color.new(color.gray, 80), linestyle=hline.style_dotted)hline(100, 'Max', color=color.new(color.gray, 80), linestyle=hline.style_dotted)lineColor = osc_raw > 0 ? bullColor : bearColorpOsc = plot(osc_scaled, 'Oscillator 1–100', color=lineColor, linewidth=2)plot(showOscillatorGradient ? osc_scaled : na, 'Osc Gradient', color=color.new(lineColor, gradientTransparency), linewidth=10)// SMA SMOOTHED + DYNAMIC COLOR + GRADIENTsmoothSignal = ta.sma(oscSignal, extraSmooth) dynSignalColor = smoothSignal > smoothSignal[1] ? signalColorBull : smoothSignal < smoothSignal[1] ? signalColorBear : color.gray // SMA PLOTpSignal = plot(showMaGradient ? smoothSignal : smoothSignal, "Signal SMA", dynSignalColor, 2)// SMA GRADIENT – 3 layersplot(showMaGradient ? smoothSignal : na, "", color.new(dynSignalColor, 60), 5)plot(showMaGradient ? smoothSignal : na, "", color.new(dynSignalColor, 35), 3)plot(showMaGradient ? smoothSignal : na, "", color.new(dynSignalColor, 0), 1)// GRADIENT FILL pMid1 = plot(osc_scaled * 0.8 + 50 * 0.2, color=na, display=display.none)pMid2 = plot(osc_scaled * 0.6 + 50 * 0.4, color=na, display=display.none)pMid3 = plot(osc_scaled * 0.4 + 50 * 0.6, color=na, display=display.none)pMid4 = plot(osc_scaled * 0.2 + 50 * 0.8, color=na, display=display.none)fill(pOsc, pMid1, color=fillEnabled ? color.new(lineColor, fillTransparency) : na)fill(pMid1, pMid2, color=fillEnabled ? color.new(lineColor, fillTransparency + 5) : na)fill(pMid2, pMid3, color=fillEnabled ? color.new(lineColor, fillTransparency + 10) : na)fill(pMid3, pMid4, color=fillEnabled ? color.new(lineColor, fillTransparency + 15) : na)// SIGNALSlongSignalObos = ta.crossover(osc_scaled, osLevel)shortSignalObos = ta.crossunder(osc_scaled, obLevel)// plotshapeplotshape(longSignalObos ? osc_scaled : na, location=location.bottom, color=osColor, style=shape.triangleup, size=size.tiny, title='Buy (OS)')plotshape(shortSignalObos ? osc_scaled : na, location=location.top, color=obColor, style=shape.triangledown, size=size.tiny, title='Sell (OB)')// ALERTS alertcondition(longSignalObos, 'Buy (Oversold)', 'Oscillator crossed above oversold.')alertcondition(shortSignalObos, 'Sell (Overbought)', 'Oscillator crossed below overbought.')
2025-12-20
163
글번호 229233
지표
답변완료
문의드립니다.
지난번에 주신 아래의 수식을 5분봉차트에서 '1시간봉의 아래의 지표'가 표현되게 하고자 합니다. 5분봉에서 30분의 아래지표를 또는 5분붕에서 2시간봉차트의 아래지표를 적용할 수 있게 하는 등 시간프레임을 변경할 수 있게 수식을 수정부탁드립니다. 도와주셔서 항상 감사드립니다. 수고하세요!!! input : BB_len(2),BB_mult(2);input : BB상단굵기(1),BB중단굵기(1),BB하단굵기(1);var : src_bb(0),basis(0),dev(0),upperBB(0),lowerBB(0);var : sellBB(False),Buybb(False);sellBB = high >= upperBB;buyBB = low <= lowerBB;input : Period1(4),mult1(0.2),st1굵기(1);input : Period2(6),mult2(1.2),st2굵기(1);input : Period3(7),mult3(1.4),st3굵기(1);var : alpha1(0),a1(0),s1(0),u1(0),d1(0),up1(0),dn1(0),tr1(1);var : alpha2(0),a2(0),s2(0),u2(0),d2(0),up2(0),dn2(0),tr2(1);var : alpha3(0),a3(0),s3(0),u3(0),d3(0),up3(0),dn3(0),tr3(1);var : st1(0),st2(0),st3(0);src_bb = open;basis = ma(src_bb, bb_len);dev = std(src_bb, bb_len);upperBB = basis + bb_mult * dev;lowerBB = basis - bb_mult * dev;plot1(upperBB, "BB Upper", red,Def,BB상단굵기);plot2(basis, "BB Basis", orange,Def,BB중단굵기); plot3(lowerBB, "BB Lower", blue,Def,BB하단굵기);alpha1 = 1 / period1;a1 = IFf(IsNan(a1[1]) == true, ma(TrueRange,period1) , alpha1 * TrueRange + (1 - alpha1) * IFf(isnan(a1[1])==true,0,a1[1]));s1 = (h+l)/2;u1 = s1 - mult1 * a1;d1 = s1 + mult1 * a1;Up1 = iff(close[1] > iff(IsNan(Up1[1])==true,0,Up1[1]) , max(u1, iff(IsNan(Up1[1])==true,0,Up1[1])) , u1);Dn1 = iff(close[1] < iff(IsNan(Dn1[1])==true,0,Dn1[1]) , min(d1, iff(IsNan(Dn1[1])==true,0,Dn1[1])) , d1);tr1 = iff(close > iff(IsNan(Dn1[1])==true,0,Dn1[1]) , 1 ,IFf(close < iff(IsNan(Up1[1])==true,0,Up1[1]) , -1 , tr1));alpha2 = 1 / period2;a2 = IFf(IsNan(a2[1]) == true, ma(TrueRange,period2) , alpha2 * TrueRange + (1 - alpha2) * IFf(isnan(a2[1])==true,0,a2[1]));s2 = (h+l)/2;u2 = s2 - mult2 * a2;d2 = s2 + mult2 * a2;Up2 = iff(close[1] > iff(IsNan(Up2[1])==true,0,Up2[1]) , max(u2, iff(IsNan(Up2[1])==true,0,Up2[1])) , u2);Dn2 = iff(close[1] < iff(IsNan(Dn2[1])==true,0,Dn2[1]) , min(d2, iff(IsNan(Dn2[1])==true,0,Dn2[1])) , d2);tr2 = iff(close > iff(IsNan(Dn2[1])==true,0,Dn2[1]) , 1 ,IFf(close < iff(IsNan(Up2[1])==true,0,Up2[1]) , -1 , tr2));alpha3 = 1 / period3;a3 = IFf(IsNan(a3[1]) == true, ma(TrueRange,period3) , alpha3 * TrueRange + (1 - alpha3) * IFf(isnan(a3[1])==true,0,a3[1]));s3 = (h+l)/2;u3 = s3 - mult3 * a3;d3 = s3 + mult3 * a3;Up3 = iff(close[1] > iff(IsNan(Up3[1])==true,0,Up3[1]) , max(u3, iff(IsNan(Up3[1])==true,0,Up3[1])) , u3);Dn3 = iff(close[1] < iff(IsNan(Dn3[1])==true,0,Dn3[1]) , min(d3, iff(IsNan(Dn3[1])==true,0,Dn3[1])) , d3);tr3 = iff(close > iff(IsNan(Dn3[1])==true,0,Dn3[1]) , 1 ,IFf(close < iff(IsNan(Up3[1])==true,0,Up3[1]) , -1 , tr3));st1 = iff(tr1 == 1 , up1 , dn1 );st2 = iff(tr2 == 1 , up2 , dn2 );st3 = iff(tr3 == 1 , up3 , dn3);plot4(st1, "ST1", iff(tr1 == 1 , green , red),Def,st1굵기);plot5(st2, "ST2", iff(tr2 == 1 , green , red),Def,st2굵기);plot6(st3, "ST3", iff(tr3 == 1 , green , red),Def,st3굵기);var : allAbove(False),allBelow(False);var : regime(0),prevRegime(0);var : bullStart(False),bearStart(False);var : buySignal(False),SellSignal(False);var : tx1(0),tx2(0);allAbove = close > st1 and close > st2 and close > st3;allBelow = close < st1 and close < st2 and close < st3;prevRegime = regime;if allAbove Then regime = 1;if allBelow Then regime = -1;bullStart = regime == 1 and prevRegime != 1 ;bearStart = regime == -1 and prevRegime != -1;if bullStart Then{ tx1 = text_new(sDate,sTime,L,"Bull"); Text_SetStyle(tx1,2,0); Text_SetColor(tx1,Green);}if bearStart Then{ tx1 = text_new(sDate,sTime,H,"Bear"); Text_SetStyle(tx1,2,1); Text_SetColor(tx1,Red);}buySignal = (regime == 1) and buyBB ;sellSignal = (regime == -1) and sellBB;if buySignal Then{ tx2 = text_new(sDate,sTime,L,"▲"); Text_SetStyle(tx2,2,0); Text_SetColor(tx2,Green);}if sellSignal Then{ tx2 = text_new(sDate,sTime,H,"▼"); Text_SetStyle(tx2,2,1); Text_SetColor(tx2,Red);}
답변완료
부탁 드려 봅니다 넘 길이가 길어서 죄송한다
This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// ©Bigtaker//@version=5indicator("Advanced custom multi MA signals (EMA/SMA/VWMA/VWAP)", shorttitle="Multi MA Signals", overlay=true)// -----------------------------------------------------------------------------// [SECTION 1] User Inputs & Configuration// -----------------------------------------------------------------------------// 1.1 Moving Average (MA) Settings (1-5)// ---------------------------------------GRP_MA01 = "=== MA 01 Settings ==="i_ma01_enabled = input.bool(true, "Show Indicator", group=GRP_MA01)i_ma01_type = input.string("EMA", "MA Type", options=["EMA", "SMA", "VWMA", "VWAP"], tooltip="VWMA: Uses Length\nVWAP: Session-based (Ignores Length)", group=GRP_MA01)i_ma01_len = input.int(50, "Length", minval=1, group=GRP_MA01)i_ma01_tf = input.timeframe("240", "Timeframe", group=GRP_MA01)i_ma01_src = input.source(close, "Source", group=GRP_MA01)i_ma01_color = input.color(color.new(#00ff88, 70), "Color", group=GRP_MA01)GRP_MA02 = "=== MA 02 Settings ==="i_ma02_enabled = input.bool(true, "Show Indicator", group=GRP_MA02)i_ma02_type = input.string("EMA", "MA Type", options=["EMA", "SMA", "VWMA", "VWAP"], group=GRP_MA02)i_ma02_len = input.int(20, "Length", minval=1, group=GRP_MA02)i_ma02_tf = input.timeframe("D", "Timeframe", group=GRP_MA02)i_ma02_src = input.source(close, "Source", group=GRP_MA02)i_ma02_color = input.color(color.new(#ffffff, 80), "Color", group=GRP_MA02)GRP_MA03 = "=== MA 03 Settings ==="i_ma03_enabled = input.bool(true, "Show Indicator", group=GRP_MA03)i_ma03_type = input.string("EMA", "MA Type", options=["EMA", "SMA", "VWMA", "VWAP"], group=GRP_MA03)i_ma03_len = input.int(50, "Length", minval=1, group=GRP_MA03)i_ma03_tf = input.timeframe("D", "Timeframe", group=GRP_MA03)i_ma03_src = input.source(close, "Source", group=GRP_MA03)i_ma03_color = input.color(color.new(#cc00ff, 70), "Color", group=GRP_MA03)GRP_MA04 = "=== MA 04 Settings ==="i_ma04_enabled = input.bool(true, "Show Indicator", group=GRP_MA04)i_ma04_type = input.string("EMA", "MA Type", options=["EMA", "SMA", "VWMA", "VWAP"], group=GRP_MA04)i_ma04_len = input.int(50, "Length", minval=1, group=GRP_MA04)i_ma04_tf = input.timeframe("W", "Timeframe", group=GRP_MA04)i_ma04_src = input.source(close, "Source", group=GRP_MA04)i_ma04_color = input.color(color.new(#fae634, 50), "Color", group=GRP_MA04)GRP_MA05 = "=== MA 05 Settings ==="i_ma05_enabled = input.bool(true, "Show Indicator", group=GRP_MA05)i_ma05_type = input.string("EMA", "MA Type", options=["EMA", "SMA", "VWMA", "VWAP"], group=GRP_MA05)i_ma05_len = input.int(100, "Length", minval=1, group=GRP_MA05)i_ma05_tf = input.timeframe("W", "Timeframe", group=GRP_MA05)i_ma05_src = input.source(close, "Source", group=GRP_MA05)i_ma05_color = input.color(color.new(#1a1ef5, 50), "Color", group=GRP_MA05)// 1.2 Signal Logic Configuration// ---------------------------------------GRP_SIG01 = ">>> Signal Option 01 (Standard) <<<"i_sig01_enabled = input.bool(true, "Enable Signal 1 (Plot & Alert)", group=GRP_SIG01)i_sig01_fast_ref = input.string("MA1", "Short MA", options=["MA1", "MA2", "MA3", "MA4", "MA5", "None"], group=GRP_SIG01)i_sig01_slow_ref = input.string("MA3", "Long MA", options=["MA1", "MA2", "MA3", "MA4", "MA5", "None"], group=GRP_SIG01)GRP_SIG02 = ">>> Signal Option 02 (Darker) <<<"i_sig02_enabled = input.bool(false, "Enable Signal 2 (Plot & Alert)", group=GRP_SIG02)i_sig02_fast_ref = input.string("MA1", "Short MA", options=["MA1", "MA2", "MA3", "MA4", "MA5", "None"], group=GRP_SIG02)i_sig02_slow_ref = input.string("MA4", "Long MA", options=["MA1", "MA2", "MA3", "MA4", "MA5", "None"], group=GRP_SIG02)GRP_SIG03 = ">>> Signal Option 03 (Darkest) <<<"i_sig03_enabled = input.bool(false, "Enable Signal 3 (Plot & Alert)", group=GRP_SIG03)i_sig03_fast_ref = input.string("MA2", "Short MA", options=["MA1", "MA2", "MA3", "MA4", "MA5", "None"], group=GRP_SIG03)i_sig03_slow_ref = input.string("MA4", "Long MA", options=["MA1", "MA2", "MA3", "MA4", "MA5", "None"], group=GRP_SIG03)// 1.3 Visual & Candle Settings// ---------------------------------------GRP_VIS_CANDLE = ">>> Candle Color Settings <<<"i_candle_override = input.bool(true, "Force Candle Color", tooltip="If enabled, hides original candles and paints new candles with specified colors.", group=GRP_VIS_CANDLE)i_candle_ref_sig = input.string("Signal 1", "Reference Signal", options=["Signal 1", "Signal 2", "Signal 3"], group=GRP_VIS_CANDLE)// 1.4 Ribbon Settings// ---------------------------------------GRP_VIS_RIBBON = ">>> Ribbon Gradient Settings <<<"i_ribbon_enabled = input.bool(true, "Enable Gradient Ribbon", group=GRP_VIS_RIBBON)i_ribbon_ref_sig = input.string("Signal 1", "Ribbon Reference Signal", options=["Signal 1", "Signal 2", "Signal 3"], tooltip="Select which signal's MAs to fill between.", group=GRP_VIS_RIBBON)i_ribbon_opacity = input.int(40, "Ribbon Opacity (Transparency)", minval=0, maxval=90, tooltip="Lower values mean darker/brighter neon effect.", group=GRP_VIS_RIBBON)// 1.5 Dashboard & Misc Settings// ---------------------------------------GRP_VIS_GENERIC = ">>> Visual Settings <<<"i_show_status_val = input.bool(false, "Show Price in Status Line", group=GRP_VIS_GENERIC)GRP_DASHBOARD = ">>> Dashboard Settings <<<"i_dash_enabled = input.bool(true, "Show Dashboard", group=GRP_DASHBOARD)i_dash_pos = input.string("Bottom Right", "Position", options=["Top Right", "Bottom Right", "Top Left", "Bottom Left"], group=GRP_DASHBOARD)i_dash_size = input.string("Small", "Size", options=["Tiny", "Small", "Normal", "Large"], group=GRP_DASHBOARD)// -----------------------------------------------------------------------------// [SECTION 2] Color Definitions (Constants)// -----------------------------------------------------------------------------c_sig01_bull = color.rgb(0, 255, 191)c_sig01_bear = color.rgb(174, 0, 255)c_sig02_bull = color.new(#00ff00, 0)c_sig02_bear = color.new(#dc0af8, 0)c_sig03_bull = color.new(#ffd900, 0)c_sig03_bear = color.new(#ff009d, 0)// -----------------------------------------------------------------------------// [SECTION 3] Calculations (MTF & MA Logic)// -----------------------------------------------------------------------------// Function: Calculate Multi-Timeframe (MTF) MAf_calc_mtf_ma(_src, _len, _tf, _type) => float _ma = na // Determine MA Type if _type == "EMA" _ma := ta.ema(_src, _len) else if _type == "SMA" _ma := ta.sma(_src, _len) else if _type == "VWMA" _ma := ta.vwma(_src, _len) // Volume Weighted else if _type == "VWAP" _ma := ta.vwap(_src) // Anchored VWAP // Request MTF Data request.security(syminfo.tickerid, _tf, _ma, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)// Calculate MAs (1-5)ma01_series = f_calc_mtf_ma(i_ma01_src, i_ma01_len, i_ma01_tf, i_ma01_type)ma02_series = f_calc_mtf_ma(i_ma02_src, i_ma02_len, i_ma02_tf, i_ma02_type)ma03_series = f_calc_mtf_ma(i_ma03_src, i_ma03_len, i_ma03_tf, i_ma03_type)ma04_series = f_calc_mtf_ma(i_ma04_src, i_ma04_len, i_ma04_tf, i_ma04_type)ma05_series = f_calc_mtf_ma(i_ma05_src, i_ma05_len, i_ma05_tf, i_ma05_type)// Function: Resolve Dropdown Selection to Seriesf_resolve_ma_series(_option_str) => float _result = na if _option_str == "MA1" _result := ma01_series else if _option_str == "MA2" _result := ma02_series else if _option_str == "MA3" _result := ma03_series else if _option_str == "MA4" _result := ma04_series else if _option_str == "MA5" _result := ma05_series _result// Strategy Logic: Crossovers & Trend Status// ---------------------------------------// [Logic Update] The 'is_trend_bull' variables now calculate status regardless of the 'enabled' toggle.// This ensures the dashboard always displays correct data. // The 'enabled' toggle is now applied only to the 'trigger' variables for plots and alerts.// Signal 1sig01_fast_ma = f_resolve_ma_series(i_sig01_fast_ref)sig01_slow_ma = f_resolve_ma_series(i_sig01_slow_ref)bool is_data_01 = not na(sig01_fast_ma) and not na(sig01_slow_ma) // Check if data existsis_trend_bull_01 = is_data_01 and (sig01_fast_ma > sig01_slow_ma)is_trend_bear_01 = is_data_01 and (sig01_fast_ma < sig01_slow_ma)trigger_buy_01 = i_sig01_enabled and is_data_01 and ta.crossover(sig01_fast_ma, sig01_slow_ma)trigger_sell_01 = i_sig01_enabled and is_data_01 and ta.crossunder(sig01_fast_ma, sig01_slow_ma)// Signal 2sig02_fast_ma = f_resolve_ma_series(i_sig02_fast_ref)sig02_slow_ma = f_resolve_ma_series(i_sig02_slow_ref)bool is_data_02 = not na(sig02_fast_ma) and not na(sig02_slow_ma)is_trend_bull_02 = is_data_02 and (sig02_fast_ma > sig02_slow_ma)is_trend_bear_02 = is_data_02 and (sig02_fast_ma < sig02_slow_ma)trigger_buy_02 = i_sig02_enabled and is_data_02 and ta.crossover(sig02_fast_ma, sig02_slow_ma)trigger_sell_02 = i_sig02_enabled and is_data_02 and ta.crossunder(sig02_fast_ma, sig02_slow_ma)// Signal 3sig03_fast_ma = f_resolve_ma_series(i_sig03_fast_ref)sig03_slow_ma = f_resolve_ma_series(i_sig03_slow_ref)bool is_data_03 = not na(sig03_fast_ma) and not na(sig03_slow_ma)is_trend_bull_03 = is_data_03 and (sig03_fast_ma > sig03_slow_ma)is_trend_bear_03 = is_data_03 and (sig03_fast_ma < sig03_slow_ma)trigger_buy_03 = i_sig03_enabled and is_data_03 and ta.crossover(sig03_fast_ma, sig03_slow_ma)trigger_sell_03 = i_sig03_enabled and is_data_03 and ta.crossunder(sig03_fast_ma, sig03_slow_ma)// -----------------------------------------------------------------------------// [SECTION 4] Visualization & Plotting// -----------------------------------------------------------------------------var display_setting = i_show_status_val ? display.all : display.pane// Plot Moving Averagesplot(i_ma01_enabled ? ma01_series : na, title="MA 01", color=i_ma01_color, linewidth=2, display=display_setting)plot(i_ma02_enabled ? ma02_series : na, title="MA 02", color=i_ma02_color, linewidth=2, display=display_setting)plot(i_ma03_enabled ? ma03_series : na, title="MA 03", color=i_ma03_color, linewidth=2, display=display_setting)plot(i_ma04_enabled ? ma04_series : na, title="MA 04", color=i_ma04_color, linewidth=2, display=display_setting)plot(i_ma05_enabled ? ma05_series : na, title="MA 05", color=i_ma05_color, linewidth=2, display=display_setting)// Plot Signal Labels (Buy/Sell)plotshape(trigger_buy_01, title="Sig1 Golden", style=shape.labelup, location=location.belowbar, color=c_sig01_bull, text="BUY", textcolor=color.rgb(28, 99, 87), size=size.small)plotshape(trigger_sell_01, title="Sig1 Death", style=shape.labeldown, location=location.abovebar, color=c_sig01_bear, text="SELL", textcolor=color.rgb(255, 255, 255), size=size.small)plotshape(trigger_buy_02, title="Sig2 Golden", style=shape.labelup, location=location.belowbar, color=c_sig02_bull, text="BUY", textcolor=color.rgb(28, 99, 87), size=size.small)plotshape(trigger_sell_02, title="Sig2 Death", style=shape.labeldown, location=location.abovebar, color=c_sig02_bear, text="SELL", textcolor=color.white, size=size.small)plotshape(trigger_buy_03, title="Sig3 Golden", style=shape.labelup, location=location.belowbar, color=c_sig03_bull, text="BUY", textcolor=color.rgb(28, 99, 87), size=size.small)plotshape(trigger_sell_03, title="Sig3 Death", style=shape.labeldown, location=location.abovebar, color=c_sig03_bear, text="SELL", textcolor=color.white, size=size.small)// Gradient Ribbon Logic// ---------------------------------------float v_ribbon_fast = nafloat v_ribbon_slow = nacolor v_ribbon_base_color = na if i_ribbon_ref_sig == "Signal 1" v_ribbon_fast := sig01_fast_ma v_ribbon_slow := sig01_slow_ma v_ribbon_base_color := sig01_fast_ma > sig01_slow_ma ? c_sig01_bull : c_sig01_bearelse if i_ribbon_ref_sig == "Signal 2" v_ribbon_fast := sig02_fast_ma v_ribbon_slow := sig02_slow_ma v_ribbon_base_color := sig02_fast_ma > sig02_slow_ma ? c_sig02_bull : c_sig02_bearelse if i_ribbon_ref_sig == "Signal 3" v_ribbon_fast := sig03_fast_ma v_ribbon_slow := sig03_slow_ma v_ribbon_base_color := sig03_fast_ma > sig03_slow_ma ? c_sig03_bull : c_sig03_bearp_ribbon_fast = plot(i_ribbon_enabled ? v_ribbon_fast : na, "Ribbon Short", display=display.none, editable=false)p_ribbon_slow = plot(i_ribbon_enabled ? v_ribbon_slow : na, "Ribbon Long", display=display.none, editable=false)color c_ribbon_near_fast = color.new(v_ribbon_base_color, i_ribbon_opacity)color c_ribbon_near_slow = color.new(v_ribbon_base_color, math.min(i_ribbon_opacity + 60, 100)) fill(p_ribbon_fast, p_ribbon_slow, v_ribbon_fast, v_ribbon_slow, c_ribbon_near_fast, c_ribbon_near_slow, title="Neon Gradient Ribbon")// Candle Coloring Logic// ---------------------------------------bool v_is_active_bull = falsebool v_is_active_bear = falsecolor v_active_col_bull = nacolor v_active_col_bear = naif i_candle_ref_sig == "Signal 1" v_is_active_bull := is_trend_bull_01 v_is_active_bear := is_trend_bear_01 v_active_col_bull := c_sig01_bull v_active_col_bear := c_sig01_bearelse if i_candle_ref_sig == "Signal 2" v_is_active_bull := is_trend_bull_02 v_is_active_bear := is_trend_bear_02 v_active_col_bull := c_sig02_bull v_active_col_bear := c_sig02_bearelse if i_candle_ref_sig == "Signal 3" v_is_active_bull := is_trend_bull_03 v_is_active_bear := is_trend_bear_03 v_active_col_bull := c_sig03_bull v_active_col_bear := c_sig03_bearcolor v_final_candle_color = naif i_candle_override if v_is_active_bull v_final_candle_color := v_active_col_bull else if v_is_active_bear v_final_candle_color := v_active_col_bear else v_final_candle_color := color.gray // Hide original candles and plot new onescolor c_transparent = color.new(color.white, 100)barcolor(i_candle_override ? c_transparent : na, editable=false)plotcandle(open, high, low, close, title = "Custom Candle", color = v_final_candle_color, wickcolor = v_final_candle_color, bordercolor = v_final_candle_color, editable = true) // -----------------------------------------------------------------------------// [SECTION 5] Dashboard UI// -----------------------------------------------------------------------------// 1. Fetch RSI Data (MTF)rsi_val_240 = request.security(syminfo.tickerid, "240", ta.rsi(close, 14), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)rsi_val_d = request.security(syminfo.tickerid, "D", ta.rsi(close, 14), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)rsi_val_w = request.security(syminfo.tickerid, "W", ta.rsi(close, 14), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)// 2. Helper: RSI Background Colorf_get_rsi_bgcolor(_val) => if na(_val) color.new(color.gray, 80) else if _val <= 30 color.new(#ff1e69, 40) // Oversold (Red) else if _val >= 70 color.new(#0bb682, 40) // Overbought (Green) else color.new(color.white, 100)// 3. Render Dashboard Tableif i_dash_enabled var pos_table = i_dash_pos == "Top Right" ? position.top_right : i_dash_pos == "Bottom Right" ? position.bottom_right : i_dash_pos == "Top Left" ? position.top_left : position.bottom_left var size_table = i_dash_size == "Tiny" ? size.tiny : i_dash_size == "Small" ? size.small : i_dash_size == "Normal" ? size.normal : size.large var table status_table = table.new(pos_table, 2, 7, bgcolor=color.new(color.black, 50), border_color=color.gray, border_width=1, frame_color=color.gray, frame_width=1) // Table Header table.cell(status_table, 0, 0, "Market Status", bgcolor=color.new(color.black, 20), text_color=color.white, text_size=size_table, width=12) table.merge_cells(status_table, 0, 0, 1, 0) // Row 1: Signal 1 Status table.cell(status_table, 0, 1, "Signal 1", text_color=color.white, text_size=size_table, text_halign=text.align_left) bool is_na_01 = not is_data_01 // Check if data exists (already calculated above) string txt_s1 = is_na_01 ? "N/A" : (is_trend_bull_01 ? "BULL" : "BEAR") color bg_s1 = is_na_01 ? color.gray : (is_trend_bull_01 ? c_sig01_bull : c_sig01_bear) table.cell(status_table, 1, 1, txt_s1, bgcolor=color.new(bg_s1, 40), text_color=color.white, text_size=size_table) // Row 2: Signal 2 Status table.cell(status_table, 0, 2, "Signal 2", text_color=color.white, text_size=size_table, text_halign=text.align_left) bool is_na_02 = not is_data_02 string txt_s2 = is_na_02 ? "N/A" : (is_trend_bull_02 ? "BULL" : "BEAR") color bg_s2 = is_na_02 ? color.gray : (is_trend_bull_02 ? c_sig02_bull : c_sig02_bear) table.cell(status_table, 1, 2, txt_s2, bgcolor=color.new(bg_s2, 40), text_color=color.white, text_size=size_table) // Row 3: Signal 3 Status table.cell(status_table, 0, 3, "Signal 3", text_color=color.white, text_size=size_table, text_halign=text.align_left) bool is_na_03 = not is_data_03 string txt_s3 = is_na_03 ? "N/A" : (is_trend_bull_03 ? "BULL" : "BEAR") color bg_s3 = is_na_03 ? color.gray : (is_trend_bull_03 ? c_sig03_bull : c_sig03_bear) table.cell(status_table, 1, 3, txt_s3, bgcolor=color.new(bg_s3, 40), text_color=color.white, text_size=size_table) // Row 4: RSI (4H) table.cell(status_table, 0, 4, "RSI (4H)", text_color=color.white, text_size=size_table, text_halign=text.align_left) color bg_rsi_240 = f_get_rsi_bgcolor(rsi_val_240) string txt_rsi_240 = na(rsi_val_240) ? "N/A" : str.tostring(rsi_val_240, "#.##") table.cell(status_table, 1, 4, txt_rsi_240, bgcolor=bg_rsi_240, text_color=color.white, text_size=size_table) // Row 5: RSI (Daily) table.cell(status_table, 0, 5, "RSI (1D)", text_color=color.white, text_size=size_table, text_halign=text.align_left) color bg_rsi_d = f_get_rsi_bgcolor(rsi_val_d) string txt_rsi_d = na(rsi_val_d) ? "N/A" : str.tostring(rsi_val_d, "#.##") table.cell(status_table, 1, 5, txt_rsi_d, bgcolor=bg_rsi_d, text_color=color.white, text_size=size_table) // Row 6: RSI (Weekly) table.cell(status_table, 0, 6, "RSI (1W)", text_color=color.white, text_size=size_table, text_halign=text.align_left) color bg_rsi_w = f_get_rsi_bgcolor(rsi_val_w) string txt_rsi_w = na(rsi_val_w) ? "N/A" : str.tostring(rsi_val_w, "#.##") table.cell(status_table, 1, 6, txt_rsi_w, bgcolor=bg_rsi_w, text_color=color.white, text_size=size_table)// -----------------------------------------------------------------------------// [SECTION 6] Alert Conditions// -----------------------------------------------------------------------------alertcondition(trigger_buy_01, title="Signal 1 Golden Cross", message="Signal1: Golden Cross")alertcondition(trigger_sell_01, title="Signal 1 Death Cross", message="Signal1: Death Cross")alertcondition(trigger_buy_02, title="Signal 2 Golden Cross", message="Signal2: Golden Cross")alertcondition(trigger_sell_02, title="Signal 2 Death Cross", message="Signal2: Death Cross")alertcondition(trigger_buy_03, title="Signal 3 Golden Cross", message="Signal3: Golden Cross")alertcondition(trigger_sell_03, title="Signal 3 Death Cross", message="Signal3: Death Cross")alertcondition(trigger_buy_01 or trigger_buy_02 or trigger_buy_03, title="Any Golden Cross", message="MA signal: Golden Cross")alertcondition(trigger_sell_01 or trigger_sell_02 or trigger_sell_03, title="Any Death Cross", message="MA signal: Death Cross")
2025-12-19
163
글번호 229225
지표