doublepattern_dachengLibrary "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)
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()
// 初始化状态对象,用于跟踪当前和历史的顶部/底部状态
// 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
= 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