OPEN-SOURCE SCRIPT
Telah dikemas kini

Very Steep & Crossed Lin Reg_Published Ver.1.1

128
このスクリプトについて/Summary of this Script
このスクリプトは、LinRegが急上昇をしている銘柄をTrading Viewのスクリーニングで発見するためのものです。LinRegが急上昇する過程で、下側の線並びに50MAなど他の指標との重なりのあるポイントでエントリーすることで、低リスクエントリーを可能にすることを狙っています。チャート上で使用するものではありません。
This script is for screening stocks that have "Very steep & crossed, triangle shaped LinReg" chart.
To find out stocks that have those shaped chart as much as possible, it helps our low risk entry strategy.


このスクリプトの目的/This Script's objective, condition & specification is as following
<目的>
TradingViewのリストにある銘柄の中から、線形回帰が急上昇して、交差している銘柄をスクリーニング結果に表出すること。
<条件>
-今日以降で線形回帰が交差するチャート
<仕様>
**Trading ViewのPine script ver5**

このスクリプトの使い方How to use this script for Trading View Pine Screening
日本語
1. チャートにPine Scriptを設定する 
2. チャート上では非表示にする (スクリーナー用のため)
3. Pineスクリーナー用のリストを作成する(新規が良い)
4. Pine Screenerの画面(jp.tradingview.com/pine-screener/)で、「スクリーニングするリストの指定」 → 「使用するPineスクリーナーの選択」をする
5. Pine ScreenerのScreener Signalの設定をする (0.1以上など)
6. スキャンを実行する
7. 結果が出た銘柄を入れるための、リストを作成する(新規)
8. Trading Viewのスーパーチャートで、目視検証をする(前提は日足で、急上昇で三角に交差しているLinReg銘柄を探すこと)

English
How to use this script for Trading View Pine Screening
1. Set Pine Script on the chart
2. Hide it on the chart (for the screener)
3. Create a list for the Pine Screener (a new one is better)
4. On the Pine Screener screen (/pine-screener/), select "Specify list to screen" → "Select Pine Screener to use"
5. Set the Screener Signal for Pine Screener (0.1 or higher, etc.)
6. Run the scan
7. Create a list (new) to put stocks with results
8. Visually verify on Trading View's Super Chart (the premise is to look for LinReg stocks that are rising sharply and crossing a triangle on the daily chart)



注意事項/Notes : Not prediction, assumption based on past data of Linear Regression
Pine Script doesn't have capability to predict future chart shape.
So, this script is developed provides selecting similar chart pattern of "steep triangle shaped linear regression" based on using past data.
Definition is as followings.
*These description will be translated in English soon, but not yet as of 24th Feb, 2025.

🔎 交差の定義
「線形回帰の上側の線と下側の線が交差する」という状況は、以下のように定義できます:

過去のデータから 上側の線と下側の線の距離が縮まっている(収束している)
その傾向が続くと 近い将来に交差する可能性がある
📌 交差の可能性を定義するための要素
以下の3つの要素を組み合わせて、交差の可能性をスクリーニングできます。

① 上側の線と下側の線の差(スプレッド)が縮小している
pinescript
コピーする
編集する
spread_now = linreg_upper - linreg_lower
spread_prev = linreg_upper[1] - linreg_lower[1]
spread_shrinking = spread_now < spread_prev
spread_now … 現在の線形回帰バンドの幅
spread_prev … 1本前のローソク足の線形回帰バンドの幅
spread_shrinking … バンド幅が縮小している(交差しそう)
② 線形回帰の上側の線の傾きが下がり、下側の線の傾きが上がっている
pinescript
コピーする
編集する
slope_upper = linreg_upper - linreg_upper[1]
slope_lower = linreg_lower - linreg_lower[1]

converging = slope_upper < 0 and slope_lower > 0
slope_upper … 上側の線の傾き(負なら下降)
slope_lower … 下側の線の傾き(正なら上昇)
converging … 上側の線が下がり、下側の線が上がっている(交差に向かっている)
③ 交差までの推定日数が近い
pinescript
コピーする
編集する
estimated_days_to_cross = spread_now / (abs(slope_upper) + abs(slope_lower))
soon_to_cross = estimated_days_to_cross < 5
estimated_days_to_cross … 交差するまでの推定日数(幅 ÷ 傾きの変化量)
soon_to_cross … 5日以内に交差しそうなら true
✅ 交差の可能性をスクリーニング
pinescript
コピーする
編集する
screener_condition = spread_shrinking and converging and soon_to_cross
spread_shrinking … 線形回帰バンドの幅が縮小
converging … 上側の線が下降し、下側の線が上昇
soon_to_cross … 5日以内に交差しそう
📌 TradingView の Pine Script に組み込む
これらの要素を組み合わせて、TradingView のスクリーニング用 Pine Script に落とし込むと、以下のようになります。

pinescript
コピーする
編集する
//version=5
indicator("Linear Regression Convergence Screener", overlay=false)

// === 設定 ===
length = 100 // 線形回帰の計算期間
mult = 2.0 // 標準偏差の倍率

// === 線形回帰の計算 ===
linreg_mid = ta.linreg(close, length, 0) // 中心線
std_dev = ta.stdev(close, length) // 標準偏差
linreg_upper = linreg_mid + (std_dev * mult) // 上側の線
linreg_lower = linreg_mid - (std_dev * mult) // 下側の線

// === 交差の可能性の判定 ===
// ① 上側の線と下側の線の差が縮小
spread_now = linreg_upper - linreg_lower
spread_prev = linreg_upper[1] - linreg_lower[1]
spread_shrinking = spread_now < spread_prev

// ② 上側の線が下がり、下側の線が上がっている
slope_upper = linreg_upper - linreg_upper[1]
slope_lower = linreg_lower - linreg_lower[1]
converging = slope_upper < 0 and slope_lower > 0

// ③ 交差までの推定日数が5日以内
estimated_days_to_cross = spread_now / (abs(slope_upper) + abs(slope_lower))
soon_to_cross = estimated_days_to_cross < 5

// === スクリーニング条件 ===
screener_condition = spread_shrinking and converging and soon_to_cross

// === プロット(スクリーニング結果) ===
plot(screener_condition ? 1 : na, title="Screener Signal", style=plot.style_columns, color=color.green)
✅ スクリプトの動作
交差する可能性のある銘柄をスクリーニング
過去のデータをもとに「バンドが縮小」「上側が下降」「下側が上昇」「5日以内に交差しそう」な銘柄を選定
TradingViewのスクリーナーで Screener Signal が 1 の銘柄をチェック
🔎 まとめ
📌 交差の可能性を定義するには?

バンドの幅が縮小
上側の線が下降し、下側の線が上昇
交差までの推定日数を計算
📌 スクリプトで交差の可能性をスクリーニング

spread_shrinking → 線形回帰バンドの幅が縮小
converging → 上側の線が下がり、下側の線が上がっている
soon_to_cross → 交差までの推定日数が5日以内
📌 TradingViewのスクリーナーで使う

plot() を追加 してエラー回避
Screener Signal が 1 の銘柄をスクリーニング
Nota Keluaran
Updated

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.