728x90
기본 RSI에 볼륨(거래량)을 고려한 트레이딩뷰 파인 스크립트입니다.
//@version=5
indicator("Snail's indicator(Volume)", overlay=true)
switch1 = input.bool(true, "1st plot On/Off")
starttime = input.time(title = "starttime", defval = timestamp("13 Sep 2022 00:00 +0000"))
anchorBarIndex = (time - starttime) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack = bar_index - anchorBarIndex
switch2 = input.bool(true, "2nd plot On/Off")
starttime2 = input.time(title = "starttime2", defval = timestamp("7 Jun 2022 00:00 +0000"))
anchorBarIndex2 = (time - starttime2) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack2 = bar_index - anchorBarIndex2
switch3 = input.bool(true, "3rd plot On/Off")
starttime3 = input.time(title = "starttime3", defval = timestamp("22 Mar 2022 00:00 +0000"))
anchorBarIndex3 = (time - starttime3) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack3 = bar_index - anchorBarIndex3
switch4 = input.bool(true, "4th plot On/Off")
starttime4 = input.time(title = "starttime4", defval = timestamp("11 Nov 2021 00:00 +0000"))
anchorBarIndex4 = (time - starttime4) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack4 = bar_index - anchorBarIndex4
switch5 = input.bool(false, "5th plot On/Off")
starttime5 = input.time(title = "starttime5", defval = timestamp("20 Dec 2022 00:00 +0000"))
anchorBarIndex5 = (time - starttime5) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack5 = bar_index - anchorBarIndex5
offset = 0
accumulated_close = 0.0
accumulated_close2 = 0.0
accumulated_close3 = 0.0
accumulated_close4 = 0.0
accumulated_close5 = 0.0
accumulated_volume = 0.0
accumulated_volume2 = 0.0
accumulated_volume3 = 0.0
accumulated_volume4 = 0.0
accumulated_volume5 = 0.0
x = anchorBarIndex
x2 = anchorBarIndex2
x3 = anchorBarIndex3
x4 = anchorBarIndex4
x5 = anchorBarIndex5
snail_ma = 0.0
snail_ma2 = 0.0
snail_ma3 = 0.0
snail_ma4 = 0.0
snail_ma5 = 0.0
close_() => close
if switch1 == true
while offset < x
accumulated_close := accumulated_close + volume[offset] * ((close[offset] + open[offset] + high[offset] + low[offset])/4)
accumulated_volume := accumulated_volume + volume[offset]
offset := offset + 1
snail_ma := accumulated_close / accumulated_volume
plot(switch1?snail_ma:na, color=color.red)
offset:=0
if switch2 == true
while offset < x2
accumulated_close2 := accumulated_close2 + volume[offset] * ((close[offset] + open[offset] + high[offset] + low[offset])/4)
accumulated_volume2 := accumulated_volume2 + volume[offset]
offset := offset + 1
snail_ma2 := accumulated_close2 / accumulated_volume2
plot(switch2?snail_ma2:na, color=color.orange)
offset:=0
if switch3 == true
while offset < x3
accumulated_close3 := accumulated_close3 + volume[offset] * ((close[offset] + open[offset] + high[offset] + low[offset])/4)
accumulated_volume3 := accumulated_volume3 + volume[offset]
offset := offset + 1
snail_ma3 := accumulated_close3 / accumulated_volume3
plot(switch3?snail_ma3:na, color=color.yellow)
offset:=0
if switch4 == true
while offset < x4
accumulated_close4 := accumulated_close4 + volume[offset] * ((close[offset] + open[offset] + high[offset] + low[offset])/4)
accumulated_volume4 := accumulated_volume4 + volume[offset]
offset := offset + 1
snail_ma4 := accumulated_close4 / accumulated_volume4
plot(switch4?snail_ma4:na, color=color.green)
offset:=0
if switch5 == true
while offset < x5
accumulated_close5 := accumulated_close5 + volume[offset] * ((close[offset] + open[offset] + high[offset] + low[offset])/4)
accumulated_volume5 := accumulated_volume5 + volume[offset]
offset := offset + 1
snail_ma5 := accumulated_close5 / accumulated_volume5
plot(switch5?snail_ma5:na, color=color.blue)
//plot(accumulated_close, "accumulated_close")
//plot(x, "x")
line ln = na
line.delete(ln[1])
ln := line.new(bar_index - 1, snail_ma, bar_index, snail_ma, width=2, color=color.purple, extend=extend.both, style=line.style_solid)
728x90
'WEB' 카테고리의 다른 글
트레이딩뷰 웹훅 alert 텔레그램으로 보내기(tradingview webhook telegram) (0) | 2023.06.08 |
---|---|
캔들 수를 반영한 이동평균선 파인 스크립트 (0) | 2023.06.05 |
docker+flask 초기 세팅 (0) | 2021.08.03 |
tomcat console 한글 깨짐 (0) | 2020.01.19 |
네이버 스마트에디터(smarteditor2) 파일 업로드 0바이트 오류 (0) | 2019.09.30 |