Dollar Américain / Yen japonais
Éducation
Mis à jour

Pine講座③ EMAを複数表示する

4 554
EMAを複数表示するのは簡単ですね。

講座②までのものを、
表示したい数だけ増やしてあげれば良いだけです。

これができれば何十本ものEMAを表示することもできます。

あんまり多いと表示に時間がかかったり、
どこかに上限があったりするとは思いますが。

=====
//version=3
study( "EMAを3本表示する" ,overlay=true )
price = input( close ,title="EMAの対象" )

length1 = input( 5 ,title="EMA1の期間" )
length2 = input( 20 ,title="EMA2の期間" )
length3 = input( 40 ,title="EMA3の期間" )

plot( ema( price ,length1 ) ,color=red )
plot( ema( price ,length2 ) ,color=blue )
plot( ema( price ,length3 ) ,color=green )
=====
Note
ご要望をいただいたので、各行に解説を追加します!

=====
//TradingView独自の宣言 PineScript ver.3で書くことを表す
//version=3

//インジケーターのコードに必須
//"" で先頭に入力したものがタイトルになる
study( "EMAを3本表示する" ,overlay=true )

//設定できる項目を指定し、その値を変数に格納
price = input( close ,title="EMAの対象" )
length1 = input( 5 ,title="EMA1の期間" )
length2 = input( 20 ,title="EMA2の期間" )
length3 = input( 40 ,title="EMA3の期間" )

// ema( ) で移動平均を算出
// plot( ) でグラフを描画
plot( ema ( price ,length1 ) ,color=red )
plot( ema ( price ,length2 ) ,color=blue )
plot( ema ( price ,length3 ) ,color=green )
=====
Note
次の講座
Pine講座④ EMAの間を塗りつぶす

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.