今回は「RSI Strategy」のコードを解説します!
※ TradingView内蔵のストラテジーを
上から順番に解説しています
※ 解説はコードの中で
このストラテジーは、エントリーしたあと、
じわじわ逆方向に動くと大変です。
あまり良いスキームではありませんね。
(ハマる値動きはあると思います)
=====
//@version=4
strategy( "RSI Strategy の解説" )
//設定の項目と初期値の指定
//RSIを計算する期間
length = input( 14 )
//買いエントリーの基準となるライン
overSold = input( 30 )
//売りエントリーの基準となるライン
overBought = input( 70 )
//計算に使う価格
price = close
//RSIの計算
vrsi = rsi(price, length)
//RSIの計算値がある
if (not na(vrsi))
//基準のライン(初期値:30)を上抜けたら
if (crossover(vrsi, overSold))
//買いエントリー
strategy.entry("RsiLE", strategy.long, comment="RsiLE")
//基準のライン(初期値:70)を下抜けたら
if (crossunder(vrsi, overBought))
//売りエントリー
strategy.entry("RsiSE", strategy.short, comment="RsiSE")
//確認用で描画
plot( vrsi )
hline( overSold )
hline( overBought )
=====
※ TradingView内蔵のストラテジーを
上から順番に解説しています
※ 解説はコードの中で
このストラテジーは、エントリーしたあと、
じわじわ逆方向に動くと大変です。
あまり良いスキームではありませんね。
(ハマる値動きはあると思います)
=====
//@version=4
strategy( "RSI Strategy の解説" )
//設定の項目と初期値の指定
//RSIを計算する期間
length = input( 14 )
//買いエントリーの基準となるライン
overSold = input( 30 )
//売りエントリーの基準となるライン
overBought = input( 70 )
//計算に使う価格
price = close
//RSIの計算
vrsi = rsi(price, length)
//RSIの計算値がある
if (not na(vrsi))
//基準のライン(初期値:30)を上抜けたら
if (crossover(vrsi, overSold))
//買いエントリー
strategy.entry("RsiLE", strategy.long, comment="RsiLE")
//基準のライン(初期値:70)を下抜けたら
if (crossunder(vrsi, overBought))
//売りエントリー
strategy.entry("RsiSE", strategy.short, comment="RsiSE")
//確認用で描画
plot( vrsi )
hline( overSold )
hline( overBought )
=====
تعليق:
次の講座