PINE LIBRARY
doublepattern_dacheng

Library "doublepattern_dacheng"
f_detect_top_bottom(x, sig, color_green, color_red, var_sequence, state)
Parameters:
x (int)
sig (bool)
color_green (color)
color_red (color)
var_sequence (array<store>)
state (TopBottomState)
store
Fields:
dir (series int)
n (series int)
y (series float)
TopBottomState
Fields:
lpt (series int)
prev_lpt (series int)
pph (series float)
ppl (series float)
cpph (series float)
cppl (series float)
ln (series int)
hn (series int)
awaiting_DBC (series int)
awaiting_DTC (series int)
tthresh (series float)
bthresh (series float)
自定义类型定义说明(Type Definitions)
该库定义了三个核心类型(type),用于结构化处理双顶双底形态识别逻辑:
This library defines three custom types to structurally manage double top/bottom pattern detection logic:
store
TopBottomState
f_detect_top_bottom() 函数
Pine Script®
f_detect_top_bottom(x, sig, color_green, color_red, var_sequence, state)
Parameters:
x (int)
sig (bool)
color_green (color)
color_red (color)
var_sequence (array<store>)
state (TopBottomState)
store
Fields:
dir (series int)
n (series int)
y (series float)
TopBottomState
Fields:
lpt (series int)
prev_lpt (series int)
pph (series float)
ppl (series float)
cpph (series float)
cppl (series float)
ln (series int)
hn (series int)
awaiting_DBC (series int)
awaiting_DTC (series int)
tthresh (series float)
bthresh (series float)
自定义类型定义说明(Type Definitions)
该库定义了三个核心类型(type),用于结构化处理双顶双底形态识别逻辑:
This library defines three custom types to structurally manage double top/bottom pattern detection logic:
store
TopBottomState
f_detect_top_bottom() 函数
// 引入库(请将 {version_code} 替换为具体版本号)
// Import the library (replace {version_code} with the actual version code)
import dachengsuper/doublepattern_dacheng/{version_code} as dp
// ====================== 以下为 M 顶 和 W 底 的检测 开始 ====================
// ====================== Start of M Top and W Bottom Detection ====================
// 用一个 store 类型的动态数组 sequence 保存最近的枢轴点(最多 3 个)
// A dynamic array of type `store` to store recent pivot points (up to 3 points)
var dp.store[] sequence = array.new<dp.store>()
// 初始化状态对象,用于跟踪当前和历史的顶部/底部状态
// Initialize a TopBottomState object to track current and historical top/bottom state
var dp.TopBottomState state = dp.TopBottomState.new(0, 0, na, na, na, na, na, na, 0, 0, 0.0, 0.0)
// 调用检测函数:检测是否形成了 M 顶 或 W 底
// Call the detection function to check for M Top or W Bottom patterns
[DTC, DBC, res_sequence, res_state] = dp.f_detect_top_bottom(x, sig, green, red, sequence, state)
// ====================== M 顶 和 W 底 的检测 结束 ====================
// ====================== End of M Top and W Bottom Detection ====================
// 当 DTC 为 true 时,表示检测到双顶形态
// When DTC is true, it indicates a double top pattern is detected
// 当 DBC 为 true 时,表示检测到双底形态
// When DBC is true, it indicates a double bottom pattern is detected
// 示例:如果需要发送 webhook 信号,请加上 `barstate.isconfirmed` 判断,这样就不会重绘
// Example: To send a webhook signal, use `DTC and barstate.isconfirmed` to avoid repainting
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
条条大路通罗马,唯独属于自己的交易逻辑最为珍贵。
All roads lead to Rome, but only your own trading logic is truly valuable.
All roads lead to Rome, but only your own trading logic is truly valuable.
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
条条大路通罗马,唯独属于自己的交易逻辑最为珍贵。
All roads lead to Rome, but only your own trading logic is truly valuable.
All roads lead to Rome, but only your own trading logic is truly valuable.
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。