[트레이딩뷰] 파인스크립트 기본

반응형

 

RSI 지표 그리기

//@version=5
indicator("WONJO_RSI_V1")
// declear variables and init
// overBuy = 70 // 과매수 
// overSell = 30 // 과매도 
overBuy = input.int(70, "과매수")
overSell = input.int(30, "과매도")
length = input.int(14, "길이", minval = 1)

h1 = hline(overBuy)
h2 = hline(overSell)

//fill 기능
fill(h1,h2,color = color.new(color.purple,90))

rsi = ta.rsi(close,length) 

plot(rsi)

 

 

20,60 이동 평균 크로스때 알람

//@version=5
//indicator("MA Cross") 
indicator("MA Cross",overlay = true) 

//입력받기
fastInput = input.int(20,"fast")
slowInput = input.int(60,"slow")

//이동평균 구하기
fastMa = ta.sma(close, fastInput)
slowMa = ta.sma(close, slowInput)

// 뚫고 올라갔는지, 내려갔는지
isOver = ta.crossover(fastMa,slowMa)
isUnder = ta.crossover(fastMa,slowMa)
if isOver
    alert("상향돌파!")
else if isUnder
    alert("하향돌파!")
    
plotshape(isOver, text = "상향돌파", style = shape.arrowup, location=location.belowbar, size=size.large,color=color.green)
plotshape(isOver, text = "하향돌파", style = shape.arrowdown, location=location.abovebar, size=size.large,color=color.red)

plot(fastMa, color=color.red)
plot(slowMa, color=color.green)

반응형