RSIの逆張りは短期足(1分足・5分足)のほうがよく効きます。
それはなぜか?
順張り手法のチャネルブレイクアウト手法(期間Nを超えたら順張りエントリー)を1分足・5分足・15分足・30分足・1時間足で検証すると、時間足が長いほうが優位性があることがわかる。
時間足が長くなるほど順張りしたほうがよくなるんです。
それをまずは共通認識を持ってから次の話に進みます。
Table of Contents
時間足が長くなるほど順張りしたほうがよくなる
トレーディングビューで確認します。
通貨ペアはなんでもOKですが今回はドル円でみていきます。
![](https://web-lukes.info/wp-content/uploads/2022/12/image-15.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-16.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-17.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-18.png)
USDJPY 1分足(チャネルブレイクアウト期間5)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-19-1024x434.png)
USDJPY 5分足(チャネルブレイクアウト期間5)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-20-1024x436.png)
USDJPY 15分足(チャネルブレイクアウト期間5)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-21-1024x420.png)
USDJPY 30分足(チャネルブレイクアウト期間5)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-22-1024x444.png)
USDJPY 1H足(チャネルブレイクアウト期間5)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-23-1024x429.png)
1分足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-112855.png)
1時間足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-113031.png)
時間足を長くするほうがだましが少ないので
時間足が長くなるほど順張りしたほうがよくなるんです。
つまり、
時間足が短くなるほど逆張りしたほうがよくなるんです。
時間足が短くなるほど逆張りしたほうがよくなる
じゃあ次は本題のRSIをみていきます。
![](https://web-lukes.info/wp-content/uploads/2022/12/image-15.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-16.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-24.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-25.png)
USDJPY 1分足(RSIストラテジー期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-26-1024x479.png)
USDJPY 5分足(RSIストラテジー期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-27-1024x492.png)
USDJPY 15分足(RSIストラテジー期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-28-1024x492.png)
USDJPY 30分足(RSIストラテジー期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-29-1024x491.png)
USDJPY 1H足(RSIストラテジー期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-30-1024x494.png)
1分足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-114331.png)
5分足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-114538.png)
1時間足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-114425.png)
なぜか1時間足のほうが強くなったw
おかしいねえ。想定と違うんだが。
そういうときは、
コードを確認してみたほうがいいな。
![](https://web-lukes.info/wp-content/uploads/2022/12/image-32.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-33.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-34-1024x508.png)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
//@version=5 strategy("RSI Strategy", overlay=true) length = input( 14 ) overSold = input( 30 ) overBought = input( 70 ) price = close vrsi = ta.rsi(price, length) co = ta.crossover(vrsi, overSold) cu = ta.crossunder(vrsi, overBought) if (not na(vrsi)) if (co) strategy.entry("RsiLE", strategy.long, comment="RsiLE") if (cu) strategy.entry("RsiSE", strategy.short, comment="RsiSE") //plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr) |
8行目と9行目を見てみてください。クロスオーバー、クロスアンダーというふうになっていますね。
![](https://web-lukes.info/wp-content/uploads/2022/12/image-35.png)
クロスオーバー、クロスアンダーなのでこのタイミングでのエントリーです。
![](https://web-lukes.info/wp-content/uploads/2022/12/image-36.png)
逆張りにしてはタイミングが遅い
本当は、
![](https://web-lukes.info/wp-content/uploads/2022/12/image-37.png)
こっちをやりたいんだけど、
そういうときは
「RSI70クロス」から「RSI70タッチ」へコードを改変します。
「RSI70クロス」から「RSI70タッチ」へコードを改変した結果
![](https://web-lukes.info/wp-content/uploads/2022/12/image-38.png)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
//@version=5 strategy("RSI Strategyの改変", overlay=true) length = input( 14 ) overSold = input( 30 ) overBought = input( 70 ) price = close vrsi = ta.rsi(price, length) // RSIが30を下回る場合 // RSIが70を上回る場合 co = vrsi < 30 cu = vrsi > 70 if (not na(vrsi)) if (co) strategy.entry("RsiLE", strategy.long, comment="RsiLE") if (cu) strategy.entry("RsiSE", strategy.short, comment="RsiSE") //plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr) |
![](https://web-lukes.info/wp-content/uploads/2022/12/image-39.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-40.png)
USDJPY 1分足(RSI到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-41-1024x486.png)
USDJPY 5分足(RSI到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-42-1024x512.png)
USDJPY 15分足(RSI到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-43-1024x504.png)
USDJPY 30分足(RSI到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-44-1024x509.png)
USDJPY 1H足(RSI到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-45-1024x508.png)
1分足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-121207.png)
5分足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-121254.png)
1時間足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-121305.png)
よし、仮説どおり
時間足が短くなるほど逆張りしたほうが良くなるぞ
そして、1分足よりも5分足のほうが効き目が高いね
次はフィルター機能をつけてストラテジーを磨くとどうなるか?
ダブルモメンタムフィルター機能をつけてみる
私が短期トレードは逆張りのほうが優位性があることを事前に知っていたのは、
本に全部書いてあったからです。
この中の第7章で
フィルターの中でも「ダブルモメンタムフィルター」が最強みたいですね。
フィルター機能とはトレードを厳選するための手法。主に上位足のトレンド方向へ逆らわないようにする。
単純に100個前のローソク足と現在のローソク足を比較して価格が下がっていたら下降トレンドとする。上昇トレンドはその逆。
モメンタム100とモメンタム200を使用。複数になると、より強いトレンドを判断できる。
つまりフィルター機能をつければ長期では順張り、短期では逆張りの瞬間を狙えるようになる。
![](https://web-lukes.info/wp-content/uploads/2022/12/image-46.png)
エントリーの条件に追加
![](https://web-lukes.info/wp-content/uploads/2022/12/image-47.png)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
//@version=5 strategy("RSI Strategyの改変", overlay=true) length = input( 14 ) overSold = input( 30 ) overBought = input( 70 ) price = close vrsi = ta.rsi(price, length) // モメンタム100 // モメンタム200 mom100 = close[0] - close[100] mom200 = close[0] - close[200] // モメンタムフィルター機能(上昇トレンド、下降トレンド) up_trend = 0 < mom100 and 0 < mom200 down_trend = 0 > mom100 and 0 > mom200 // RSIが30を下回る場合+上昇トレンド // RSIが70を上回る場合+下降トレンド co = vrsi < 30 and up_trend cu = vrsi > 70 and down_trend if (not na(vrsi)) if (co) strategy.entry("RsiLE", strategy.long, comment="RsiLE") if (cu) strategy.entry("RsiSE", strategy.short, comment="RsiSE") //plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr) |
USDJPY 1分足(RSI到達 期間14+モメンタムダブルフィルター)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-48-1024x488.png)
USDJPY 5分足(RSI到達 期間14+モメンタムダブルフィルター)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-49-1024x496.png)
USDJPY 15分足(RSI到達 期間14+モメンタムダブルフィルター)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-50-1024x480.png)
USDJPY 30分足(RSI到達 期間14+モメンタムダブルフィルター)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-51-1024x486.png)
USDJPY 1H足(RSI到達 期間14+モメンタムダブルフィルター)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-52-1024x478.png)
1分足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-125123.png)
5分足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-125137.png)
1時間足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-125150.png)
不安定だが、全体的に収益が改善された。
ここで疑問なんですが、フィルター機能をつけない5分足のほうが強いのはおかしくないですか?
TradingViewの無料プランでは長い期間のバックテストが実行できないのもそうですが、
エントリータイミングと決済タイミングが同じなのでドテン仕様になっています。
何が問題なのかというと、エントリータイミングが少ないのでポジションを常に持つ状態なので収支結果が不安定になります。
そこでエントリータイミングにはフィルター機能をつけて、決済タイミングはフィルター機能を外します。
・エントリールール
・決済ルール
が必要
決済ルールをつける
ドテン仕様から決済ルールを追加して、ストラテジーをさらに磨きます。
決済ルールもRSIを使いまわします。
RSIは60、40を使います。
条件式
- ポジションを保有状態
- RSIタッチ
Pine Scriptでポジションを保有状態を確認する
![](https://web-lukes.info/wp-content/uploads/2022/12/image-53.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-54.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-55.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-56.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-57.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-62-1024x172.png)
ポジション保有状態は、プログラムで翻訳すると、
ポジションサイズが0よりも大きい場合はロングポジションを保有
Pine Scriptではstrategy.position_sizeにロング保有状態なら正の小数、ショート保有状態なら負の小数が入ってる
Pine Scriptではトレードの機能を呼び出す場合はstrategy.を使う
Pine Scriptでは条件分岐にはif ~ と改行してスペース4個つけると条件分岐式を書ける
![](https://web-lukes.info/wp-content/uploads/2022/12/image-60.png)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-63-1024x243.png)
サンプルコード全文
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
//@version=5 strategy("RSI Strategyの改変", overlay=true) length = input( 14 ) overSold = input( 30 ) overBought = input( 70 ) price = close vrsi = ta.rsi(price, length) // モメンタム100 // モメンタム200 mom100 = close[0] - close[100] mom200 = close[0] - close[200] // モメンタムフィルター機能(上昇トレンド、下降トレンド) up_trend = 0 < mom100 and 0 < mom200 down_trend = 0 > mom100 and 0 > mom200 // RSIが30を下回る場合+上昇トレンド // RSIが70を上回る場合+下降トレンド co = vrsi < 30 and up_trend cu = vrsi > 70 and down_trend if (not na(vrsi)) if (co) strategy.entry("RsiLE", strategy.long, comment="RsiLE") if (cu) strategy.entry("RsiSE", strategy.short, comment="RsiSE") //plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr) //条件分岐「もしもポジションが0を超えている」and「RSIが60をタッチ」で決済 if 0 < strategy.position_size and vrsi > 60 strategy.close_all() //条件分岐「もしもポジションが0未満」and「RSIが40をタッチ」で決済 if 0 > strategy.position_size and vrsi < 40 strategy.close_all() |
USDJPY 1分足(エントリー:RSI70・30到達 期間14+モメンタムダブルフィルター、決済:RSI60・40到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-64-1024x513.png)
USDJPY 5分足(エントリー:RSI70・30到達 期間14+モメンタムダブルフィルター、決済:RSI60・40到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-65-1024x517.png)
USDJPY 15分足(エントリー:RSI70・30到達 期間14+モメンタムダブルフィルター、決済:RSI60・40到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-66-1024x509.png)
USDJPY 30分足(エントリー:RSI70・30到達 期間14+モメンタムダブルフィルター、決済:RSI60・40到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-67-1024x487.png)
USDJPY 1H足(エントリー:RSI70・30到達 期間14+モメンタムダブルフィルター、決済:RSI60・40到達 期間14)
![](https://web-lukes.info/wp-content/uploads/2022/12/image-68-1024x515.png)
1分足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-133618.png)
5分足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-133601.png)
1時間足
![](https://web-lukes.info/wp-content/uploads/2022/12/スクリーンショット-2022-12-24-133542.png)
RSIの逆張り手法はFXで勝てるのか検証したらガチだった。
まとめ
RSIには優位性がありそうです。
ポートフォリオにいれてみたいと思いますw
次回ストラテジーのMT4のEA化。
BybitがGoogleのIPアドレス規制をしているためです。国内のVPSなら使…
自分のbotで使ってるAPIキーを使用しているんですが、 You have br…
pybit 最新版にコードを変更しました。コードとrequirements.tx…
お返事ありがとうございます。はい。pybit==2.3.0になっております。
コードはあっていると思います。rewuirements.txtは「pybit==…