Search
Products
Community
Markets
News
Brokers
More
IN
Get started
U.S. Dollar / Japanese Yen
Education
Updated
Aug 2, 2019
Pine講座㉞ バックテスト|Momentum Strategy の解説(相場の勢いをもとに途転売買)
2
1
Grab this chart
Grab this chart
Aug 1, 2019
相場の勢いをみるモメンタムをもとにした
TradingView内蔵のストラテジーの解説です。
モメンタムといっても仕組みは大変シンプルで、
「終値を一定期間さかのぼって比較するだけ」です。
このストラテジーは、モメンタムの確認を2段階で行っていました。
解説はコードの中に記載しています。
=====
//
version
=4
strategy( "Momentum Strategy の解説" )
length = input( 12 )
price = close
//モメンタム(勢い)を算出する関数を作成
//seria(数値)とlength分さかのぼった seria を比較
momentum( seria, length ) => seria - seria[length]
//終値をlength分さかのぼって比較
mom0 = momentum( price, length )
//mom0を1本さかのぼって比較
mom1 = momentum( mom0, 1 )
//mom0 と mom1 がプラスのとき
if ( mom0 > 0 and mom1 > 0 )
//高値+1ティックで逆指値を発注
strategy.entry( "MomLE", strategy.long, stop=high+syminfo.mintick, comment="MomLE" )
//上の条件を満たさないとき
else
//上の逆指値注文をキャンセル
strategy.cancel( "MomLE" )
//mom0 と mom1 がマイナスのとき
if ( mom0 < 0 and mom1 < 0 )
//安値-1ティックで逆指値を発注
strategy.entry( "MomSE", strategy.short, stop=low-syminfo.mintick, comment="MomSE" )
//条件を満たさないときは逆指値注文をキャンセル
else
strategy.cancel( "MomSE" )
//確認用で描画
plot( mom0 ,color=color.red )
plot( mom1 )
=====
Aug 2, 2019
Note
次の講座
yuya_takahashi_
Follow
小次郎講師公式インジケーターのお申込
bit.ly/2vdSV4Q
小次郎講師のLINE@
bit.ly/2VZQFu3
小次郎講師のチャート情報局
bit.ly/2GvLAEp
Also on:
Beyond Technical Analysis
pinescript
yuya_takahashi_
Follow
小次郎講師公式インジケーターのお申込
bit.ly/2vdSV4Q
小次郎講師のLINE@
bit.ly/2VZQFu3
小次郎講師のチャート情報局
bit.ly/2GvLAEp
Also on:
Related publications
Pine講座① たった2行で移動平均線が出せる
by yuya_takahashi_
Pine講座㉕ TradingViewでバックテストをする
by yuya_takahashi_
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the
Terms of Use
.