OPEN-SOURCE SCRIPT
更新済 Logarithmic Regression Up Trend Screener [BigBeluga]

//version=5
// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
// Modified for screener to find all upward trends by Gemini
indicator("Logarithmic Regression Up Trend Screener [BigBeluga]", "LogReg Up Trend Screener [BigBeluga]", overlay=true)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(100, "Lookback Period", minval=1)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Function to compute logarithmic regression
f_log_regression(src, length) =>
float sumX = 0.0
float sumY = 0.0
float sumXSqr = 0.0
float sumXY = 0.0
for i = 0 to length - 1
val = math.log(src)
per = i + 1.0
sumX += per
sumY += val
sumXSqr += per * per
sumXY += val * per
slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX)
average = sumY / length
intercept = average - slope * sumX / length + slope
[slope, intercept]
// Calculate slope and intercept
[slope, intercept] = f_log_regression(close, length)
float start = math.exp(intercept + slope * length)
float end = math.exp(intercept)
// Screener Condition: Channel is in an uptrend (this covers both "just turned up" and "already up")
bool isUptrend = end > start
// }
// PLOT FOR SCREENER ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Plot '1' if the channel is up, otherwise plot '0'.
// The screener can then filter for stocks where the value of "Uptrend Signal" is equal to 1.
plot(isUptrend ? 1 : 0, "Uptrend Signal", display=display.none)
// Optional: Display a visual signal on the chart for confirmation.
// The background will be green as long as the channel is in an uptrend.
bgcolor(isUptrend ? color.new(color.green, 90) : na)
// }
// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
// Modified for screener to find all upward trends by Gemini
indicator("Logarithmic Regression Up Trend Screener [BigBeluga]", "LogReg Up Trend Screener [BigBeluga]", overlay=true)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(100, "Lookback Period", minval=1)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Function to compute logarithmic regression
f_log_regression(src, length) =>
float sumX = 0.0
float sumY = 0.0
float sumXSqr = 0.0
float sumXY = 0.0
for i = 0 to length - 1
val = math.log(src)
per = i + 1.0
sumX += per
sumY += val
sumXSqr += per * per
sumXY += val * per
slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX)
average = sumY / length
intercept = average - slope * sumX / length + slope
[slope, intercept]
// Calculate slope and intercept
[slope, intercept] = f_log_regression(close, length)
float start = math.exp(intercept + slope * length)
float end = math.exp(intercept)
// Screener Condition: Channel is in an uptrend (this covers both "just turned up" and "already up")
bool isUptrend = end > start
// }
// PLOT FOR SCREENER ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Plot '1' if the channel is up, otherwise plot '0'.
// The screener can then filter for stocks where the value of "Uptrend Signal" is equal to 1.
plot(isUptrend ? 1 : 0, "Uptrend Signal", display=display.none)
// Optional: Display a visual signal on the chart for confirmation.
// The background will be green as long as the channel is in an uptrend.
bgcolor(isUptrend ? color.new(color.green, 90) : na)
// }
リリースノート
//version=5// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
// Modified for a dual-condition screener by Gemini
indicator("LogReg Dual Signal Screener [BigBeluga]", "LogReg Dual Screener [BigBeluga]", overlay=true)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(100, "Lookback Period", minval=1)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Function to compute logarithmic regression
f_log_regression(src, length) =>
float sumX = 0.0
float sumY = 0.0
float sumXSqr = 0.0
float sumXY = 0.0
for i = 0 to length - 1
val = math.log(src)
per = i + 1.0
sumX += per
sumY += val
sumXSqr += per * per
sumXY += val * per
slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX)
average = sumY / length
intercept = average - slope * sumX / length + slope
[slope, intercept]
// Calculate slope and intercept
[slope, intercept] = f_log_regression(close, length)
float start = math.exp(intercept + slope * length)
float end = math.exp(intercept)
// --- Define the two separate conditions ---
bool isUptrend = end > start
// Condition 1: Channel just turned from down to up
bool justTurnedUp = isUptrend and not isUptrend[1]
// Condition 2: Channel was already in an uptrend
bool alreadyUp = isUptrend and isUptrend[1]
// }
// PLOT FOR SCREENER ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Assign a numerical value for each condition
// 1 = Just Turned Up
// 2 = Already in an Uptrend
// 0 = Downtrend
float screenerValue = justTurnedUp ? 1 : alreadyUp ? 2 : 0
// Plot the value for the screener to read. This plot is not visible on the chart.
plot(screenerValue, "Trend Signal", display=display.none)
// Optional: Display different background colors on the chart for visual confirmation.
// Bright Green for the turnaround signal, a softer green for the continuation.
color bgColor = justTurnedUp ? color.new(color.lime, 80) : alreadyUp ? color.new(color.green, 90) : na
bgcolor(bgColor)
// }
リリースノート
//version=5// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org/licenses/by-nc-sa/4.0/
// © BigBeluga
// Modified for a user-selectable screener by Gemini
indicator("LogReg Selectable Screener [BigBeluga]", "LogReg Selectable Screener [BigBeluga]", overlay=true)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
string signalType = input.string("Just Turned Up", "Signal to Screen For", options = ["Just Turned Up", "Already In Uptrend"], tooltip="Choose which signal you want the screener to look for. The filter condition in the screener should always be set to 'equals 1'.")
int length = input.int(100, "Lookback Period", minval=1)
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Function to compute logarithmic regression
f_log_regression(src, length) =>
float sumX = 0.0
float sumY = 0.0
float sumXSqr = 0.0
float sumXY = 0.0
for i = 0 to length - 1
val = math.log(src)
per = i + 1.0
sumX += per
sumY += val
sumXSqr += per * per
sumXY += val * per
slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX)
average = sumY / length
intercept = average - slope * sumX / length + slope
[slope, intercept]
// Calculate slope and intercept from the logarithmic regression
[slope, intercept] = f_log_regression(close, length)
float start = math.exp(intercept + slope * length)
float end = math.exp(intercept)
// --- Define the two separate boolean conditions ---
bool isUptrend = end > start
bool justTurnedUp = isUptrend and not isUptrend[1]
bool alreadyUp = isUptrend and isUptrend[1]
// --- Determine if the selected condition is met ---
bool conditionMet = false
if signalType == "Just Turned Up"
conditionMet := justTurnedUp
else if signalType == "Already In Uptrend"
conditionMet := alreadyUp
// }
// PLOT FOR SCREENER ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Plot '1' if the user-selected condition is met, otherwise plot '0'.
plot(conditionMet ? 1 : 0, "Signal Active", display=display.none)
// Optional: Display background colors on the chart to visually confirm which signal is active.
color bgColor = na
if conditionMet
bgColor := (signalType == "Just Turned Up") ? color.new(color.lime, 80) : color.new(color.green, 90)
bgcolor(bgColor)
// }
リリースノート
//version=5// © BigBeluga
// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// creativecommons.org/licenses/by-nc-sa/4.0/
// Modified into a screener-friendly indicator.
indicator("Logarithmic Regression Screener Indicator [BigBeluga Mod]", "LogReg Screener Ind [BigBeluga Mod]", overlay=false)
// INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
int length = input.int(100, "Lookback Period", group = "Parameters")
string screener_type = input.string("Log Regression Channel", "Screener Type", options = ["Log Regression Channel", "Logarithmic Regression"], group = "Screener Settings")
// }
// CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Function to compute logarithmic regression
f_log_regression(src, length) =>
float sumX = 0.0
float sumY = 0.0
float sumXSqr = 0.0
float sumXY = 0.0
for i = 0 to length - 1
val = math.log(src)
per = i + 1.0
sumX += per
sumY += val
sumXSqr += per * per
sumXY += val * per
slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX)
average = sumY / length
intercept = average - slope * sumX / length + slope
[slope, intercept]
// Calculate slope and intercept
[slope, intercept] = f_log_regression(close, length)
float start = math.exp(intercept + slope * length)
float end = math.exp(intercept)
// }
// SCREENING LOGIC ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// --- Define conditions ---
bool logChannelUp = end > start
bool logChannelDown = end < start
bool logTrendUp = end > end[3]
bool logTrendDown = end < end[3]
// --- Determine the final signal based on user input ---
int screener_signal = 0 // Default to 0 (Neutral)
if screener_type == "Log Regression Channel"
if logChannelUp
screener_signal := 1
else if logChannelDown
screener_signal := -1
else if screener_type == "Logarithmic Regression"
if logTrendUp
screener_signal := 1
else if logTrendDown
screener_signal := -1
// }
// OUTPUT & VISUALS ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{
// Plot the signal for the screener to read. display.none hides it from the chart pane.
plot(screener_signal, "Screener Signal", display = display.none)
// --- Visual Confirmation on Chart ---
// Use background color to show the current state on the chart.
bgcolor(screener_signal == 1 ? color.new(color.green, 80) : screener_signal == -1 ? color.new(color.red, 80) : na, title="Signal Background")
// Plot a simplified visual representation in its own pane
plot(screener_signal, "Signal", style=plot.style_columns, color=(screener_signal == 1 ? color.green : screener_signal == -1 ? color.red : color.gray))
// --- Alerts ---
alertcondition(screener_signal == 1, title="Signal UP", message="{{ticker}}: {{screener_type}} signal is UP")
alertcondition(screener_signal == -1, title="Signal DOWN", message="{{ticker}}: {{screener_type}} signal is DOWN")
// }
オープンソーススクリプト
TradingViewの精神に則り、この作者はスクリプトのソースコードを公開しているので、その内容を理解し検証することができます。作者に感謝です!無料でお使いいただけますが、このコードを投稿に再利用する際にはハウスルールに従うものとします。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、この作者はスクリプトのソースコードを公開しているので、その内容を理解し検証することができます。作者に感謝です!無料でお使いいただけますが、このコードを投稿に再利用する際にはハウスルールに従うものとします。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。