見出し画像

他の時間足でも日足移動平均線を表示したい【TradingView】

スクリプトの説明

1時間足や5分足チャートで5日移動平均線や25日移動平均線を表示するスクリプトです

実装方法

https://youtu.be/-NFE0xZ4J14
この動画の(2:21~)で説明しています。

注意!!

スクリプトの利用は自己責任でお願い致します。
何かしらの不備があった場合も責任は負いかねますので、
使用の際にはスクリプトの確認をお願い致します。

スクリプト

//@version=4
study(title="Fixed_MA", overlay=true, resolution="")

//入力
dis1 = input(true, title="Display MA1")
len1 = input(defval=5, title="Length1", minval=1)
src1 = input(close, title="Source1")
time_f_1 = input(title="Time Frame1", type=input.resolution, defval="D")

dis2 = input(true, title="Display MA2")
len2 = input(defval=25, title="Length2", minval=1)
src2 = input(close, title="Source2")
time_f_2 = input(title="Time Frame2", type=input.resolution, defval="D")

dis3 = input(true, title="Display MA3")
len3 = input(defval=75, title="Length3", minval=1)
src3 = input(close, title="Source3")
time_f_3 = input(title="Time Frame3", type=input.resolution, defval="D")

//移動平均線
out1 = dis1 ? security(symbol=syminfo.tickerid, resolution=time_f_1, expression=sma(src1, len1), gaps= barmerge.gaps_on) : na
out2 = dis2 ? security(symbol=syminfo.tickerid, resolution=time_f_2, expression=sma(src2, len2), gaps= barmerge.gaps_on) : na
out3 = dis3 ? security(symbol=syminfo.tickerid, resolution=time_f_3, expression=sma(src3, len3), gaps= barmerge.gaps_on) : na

//出力
plot(out1, title="MA1", color=color.yellow, linewidth=2, transp=0)
plot(out2, title="MA2", color=color.orange, linewidth=2, transp=0)
plot(out3, title="MA3", color=color.purple, linewidth=2, transp=0)

この記事が気に入ったらサポートをしてみませんか?