커뮤니티

변환 부탁 드립니다.

프로필 이미지
다올
2025-11-17 17:50:11
85
글번호 228127
답변완료

//트레이딩 뷰 지표입니다....변환 부탁드립니다.

//@version=5 indicator('[@btc_charlie] Trader XO Macro Trend Scanner', overlay=true)

// Variables var ok = 0 var countBuy = 0 var countSell = 0 src = input(close, title='OHLC Type') i_fastEMA = input(12, title='Fast EMA') i_slowEMA = input(25, title='Slow EMA') i_defEMA = input(25, title='Consolidated EMA')

// Allow the option to show single or double EMA i_bothEMAs = input(title='Show Both EMAs', defval=true)

// Define EMAs v_fastEMA = ta.ema(src, i_fastEMA) v_slowEMA = ta.ema(src, i_slowEMA) v_biasEMA = ta.ema(src, i_defEMA)

// Color the EMAs emaColor = v_fastEMA > v_slowEMA ? color.green : v_fastEMA < v_slowEMA ? color.red : #FF530D

// Plot EMAs plot(i_bothEMAs ? na : v_biasEMA, color=emaColor, linewidth=3, title='Consolidated EMA') plot(i_bothEMAs ? v_fastEMA : na, title='Fast EMA', color=emaColor) plot(i_bothEMAs ? v_slowEMA : na, title='Slow EMA', color=emaColor)

// Colour the bars buy = v_fastEMA > v_slowEMA sell = v_fastEMA < v_slowEMA

if buy     countBuy += 1     countBuy

if buy     countSell := 0     countSell

if sell     countSell += 1     countSell

if sell     countBuy := 0     countBuy

buysignal = countBuy < 2 and countBuy > 0 and countSell < 1 and buy and not buy[1] sellsignal = countSell > 0 and countSell < 2 and countBuy < 1 and sell and not sell[1]

barcolor(buysignal ? color.green : na) barcolor(sellsignal ? color.red : na)

// Plot Bull/Bear

plotshape(buysignal, title='Bull', text='Bull', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.black, 0), size=size.tiny) plotshape(sellsignal, title='Bear', text='Bear', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.black, 0), size=size.tiny)

bull = countBuy > 1 bear = countSell > 1

barcolor(bull ? color.green : na) barcolor(bear ? color.red : na)

// Set Alerts

alertcondition(ta.crossover(v_fastEMA, v_slowEMA), title='Bullish EMA Cross', message='Bullish EMA crossover') alertcondition(ta.crossunder(v_fastEMA, v_slowEMA), title='Bearish EMA Cross', message='Bearish EMA Crossover')

// Stoch RSI code

smoothK = input.int(3, 'K', minval=1) smoothD = input.int(3, 'D', minval=1) lengthRSI = input.int(14, 'RSI Length', minval=1) lengthStoch = input.int(14, 'Stochastic Length', minval=1)

rsi1 = ta.rsi(src, lengthRSI) k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK) d = ta.sma(k, smoothD)

bandno0 = input.int(80, minval=1, title='Upper Band', group='Bands (change this instead of length in Style for Stoch RSI colour to work properly)') bandno2 = input.int(50, minval=1, title='Middle Band', group='Bands (change this instead of length in Style for Stoch RSI colour to work properly)') bandno1 = input.int(20, minval=1, title='Lower Band', group='Bands (change this instead of length in Style for Stoch RSI colour to work properly)')

// Alerts

crossoverAlertBgColourMidOnOff = input.bool(title='Crossover Alert Background Colour (Middle Level) [ON/OFF]', group='Crossover Alerts', defval=false) crossoverAlertBgColourOBOSOnOff = input.bool(title='Crossover Alert Background Colour (OB/OS Level) [ON/OFF]', group='Crossover Alerts', defval=false)

crossoverAlertBgColourGreaterThanOnOff = input.bool(title='Crossover Alert >input [ON/OFF]', group='Crossover Alerts', defval=false) crossoverAlertBgColourLessThanOnOff = input.bool(title='Crossover Alert <input [ON/OFF]', group='Crossover Alerts', defval=false)

maTypeChoice = input.string('EMA', title='MA Type', group='Moving Average', options=['EMA', 'WMA', 'SMA', 'None']) maSrc = input.source(close, title='MA Source', group='Moving Average') maLen = input.int(200, minval=1, title='MA Length', group='Moving Average')

maValue = if maTypeChoice == 'EMA'     ta.ema(maSrc, maLen) else if maTypeChoice == 'WMA'     ta.wma(maSrc, maLen) else if maTypeChoice == 'SMA'     ta.sma(maSrc, maLen) else     0

crossupCHECK = maTypeChoice == 'None' or open > maValue and maTypeChoice != 'None' crossdownCHECK = maTypeChoice == 'None' or open < maValue and maTypeChoice != 'None'

crossupalert = crossupCHECK and ta.crossover(k, d) and (k < bandno2 or d < bandno2) crossdownalert = crossdownCHECK and ta.crossunder(k, d) and (k > bandno2 or d > bandno2) crossupOSalert = crossupCHECK and ta.crossover(k, d) and (k < bandno1 or d < bandno1) crossdownOBalert = crossdownCHECK and ta.crossunder(k, d) and (k > bandno0 or d > bandno0)

aboveBandalert = ta.crossunder(k, bandno0) belowBandalert = ta.crossover(k, bandno1)

bgcolor(color=crossupalert and crossoverAlertBgColourMidOnOff ? #4CAF50 : crossdownalert and crossoverAlertBgColourMidOnOff ? #FF0000 : na, title='Crossover Alert Background Colour (Middle Level)', transp=70) bgcolor(color=crossupOSalert and crossoverAlertBgColourOBOSOnOff ? #fbc02d : crossdownOBalert and crossoverAlertBgColourOBOSOnOff ? #000000 : na, title='Crossover Alert Background Colour (OB/OS Level)', transp=70)

bgcolor(color=aboveBandalert and crossoverAlertBgColourGreaterThanOnOff ? #ff0014 : crossdownalert and crossoverAlertBgColourMidOnOff ? #FF0000 : na, title='Crossover Alert - K > Upper level', transp=70) bgcolor(color=belowBandalert and crossoverAlertBgColourLessThanOnOff ? #4CAF50 : crossdownalert and crossoverAlertBgColourMidOnOff ? #FF0000 : na, title='Crossover Alert - K < Lower level', transp=70)

alertcondition(crossupalert or crossdownalert, title='Stoch RSI Crossover', message='STOCH RSI CROSSOVER')

지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-11-18 14:05:45

안녕하세요 예스스탁입니다. input : i_fastEMA(12); input : i_slowEMA(25); input : i_defEMA(25); input : i_bothEMAs(true); var : ok(0),countBuy(0),countSell(0); var : src(0),v_fastEMA(0),v_slowEMA(0),v_biasEMA(0),emaColor(0); src = close; // Define EMAs v_fastEMA = ema(src, i_fastEMA); v_slowEMA = ema(src, i_slowEMA); v_biasEMA = ema(src, i_defEMA); emaColor = iff(v_fastEMA > v_slowEMA ,green , iff(v_fastEMA < v_slowEMA , red , Black)); // Plot EMAs if i_bothEMAs == true Then { NoPlot(1); plot2(v_fastEMA, "Fast EMA", emaColor); plot3(v_slowEMA, "Slow EMA", emaColor); } Else { plot1(v_biasEMA, "Consolidated EMA",emaColor); NoPlot(2); NoPlot(3); } var : B(False),S(False),buysignal(False),sellsignal(False); B = v_fastEMA > v_slowEMA; S = v_fastEMA < v_slowEMA; if B == true Then { countBuy = countBuy+1; countSell = 0; } if S == true Then { countSell = countSell+1; countBuy = 0; } buysignal = countBuy < 2 and countBuy > 0 and countSell < 1 and b and b[1] == False; sellsignal = countSell > 0 and countSell < 2 and countBuy < 1 and s and s[1] == False; var : tx(0); if buysignal == true Then { tx = Text_New(sDate,sTime,L,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Green); } if sellsignal == true Then { tx = Text_New(sDate,sTime,H,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,red); } var : bull(False),bear(False); bull = countBuy > 1; bear = countSell > 1; #barcolor(bull ? color.green : na) #barcolor(bear ? color.red : na) input : smoothK(3); input : smoothD(3); input : lengthRSI(14); input : lengthStoch(14); var : rsi1(0),f(0),k(0),d(0); rsi1 = rsi(lengthRSI); f = (rsi1-lowest(rsi1,lengthStoch))/(highest(rsi1,lengthStoch)-lowest(rsi1,lengthStoch))*100; k = ma(f, smoothK); d = ma(k, smoothD); input : bandno0(80); input : bandno2(50); input : bandno1(20); input : crossoverAlertBgColourMidOnOff(false); input : crossoverAlertBgColourOBOSOnOff(false); input : crossoverAlertBgColourGreaterThanOnOff(false); input : crossoverAlertBgColourLessThanOnOff(false); input : maTypeChoice(1);#1:EMA, 2:WMA, 3:SMA,4:none input : maLen(200); var : maSrc(0),maValue(0),crossupCHECK(False),crossdownCHECK(False); maSrc = close; if maTypeChoice == 1 Then maValue = ema(maSrc, maLen); Else if maTypeChoice == 2 Then maValue = wma(maSrc, maLen); else if maTypeChoice == 3 Then maValue = ma(maSrc, maLen); else maValue = 0; crossupCHECK = maTypeChoice == 4 or open > maValue and maTypeChoice != 4; crossdownCHECK = maTypeChoice == 4 or open < maValue and maTypeChoice != 4; var : crossupalert(False),crossdownalert(False),crossupOSalert(False),crossdownOBalert(False); var : aboveBandalert(False),belowBandalert(False); crossupalert = crossupCHECK and CrossUp(k, d) and (k < bandno2 or d < bandno2); crossdownalert = crossdownCHECK and CrossDown(k, d) and (k > bandno2 or d > bandno2); crossupOSalert = crossupCHECK and CrossUp(k, d) and (k < bandno1 or d < bandno1); crossdownOBalert = crossdownCHECK and CrossDown(k, d) and (k > bandno0 or d > bandno0); aboveBandalert = CrossDown(k, bandno0); belowBandalert = CrossUp(k, bandno1); var : TL1(0),TL2(0),TL3(0),TL4(0); if crossupalert and crossoverAlertBgColourMidOnOff Then { TL1 = TL_New(sDate,sTime,0,sDate,sTime,9999999999); TL_SetColor(TL1,Lime); } if crossdownalert and crossoverAlertBgColourMidOnOff Then { TL1 = TL_New(sDate,sTime,0,sDate,sTime,9999999999); TL_SetColor(TL1,Red); } if crossupOSalert and crossoverAlertBgColourOBOSOnOff Then { TL2 = TL_New(sDate,sTime,0,sDate,sTime,9999999999); TL_SetColor(TL2,Yellow); } if crossdownOBalert and crossoverAlertBgColourOBOSOnOff Then { TL2 = TL_New(sDate,sTime,0,sDate,sTime,9999999999); TL_SetColor(TL2,Black); } if aboveBandalert and crossoverAlertBgColourGreaterThanOnOff Then { TL3 = TL_New(sDate,sTime,0,sDate,sTime,9999999999); TL_SetColor(TL3,Red); } if crossdownalert and crossoverAlertBgColourMidOnOff Then { TL3 = TL_New(sDate,sTime,0,sDate,sTime,9999999999); TL_SetColor(TL3,Red); } if belowBandalert and crossoverAlertBgColourLessThanOnOff Then { TL4 = TL_New(sDate,sTime,0,sDate,sTime,9999999999); TL_SetColor(TL4,Red); } if crossdownalert and crossoverAlertBgColourMidOnOff Then { TL4 = TL_New(sDate,sTime,0,sDate,sTime,9999999999); TL_SetColor(TL4,Red); } 즐거운 하루되세요