如何让 Pinescript 计数?
How To Get Pinescript To Count?
我目前正在尝试制作一个脚本,该脚本基本上会计算图表中看涨信号的数量,然后在每个包含这些信号的烛台上方绘制看涨信号的数量。
我已经定义了模式、变量和信号。
只是需要帮助制作情节。我不知道如何让它正确地计算信号,
然后在烛台上显示该数字。
谢谢解答!!!
(更喜欢 V4,但任何答案都很好!)
//@version=4
study("", overlay = true, max_labels_count = 500)
bull_cond1 = crossover(ema(close,13), ema(close,20))
bull_cond2 = close > open
bull_cond3 = close > close[2]
bool global_bull_cond = bull_cond1 or bull_cond2 or bull_cond3
int bull_count = 0
if global_bull_cond
if bull_cond1
bull_count += 1
if bull_cond2
bull_count += 1
if bull_cond3
bull_count += 1
label.new(x = bar_index, y = high, style = label.style_label_down, size = size.tiny, color = color.lime, textcolor = color.black, text = tostring(bull_count))
我目前正在尝试制作一个脚本,该脚本基本上会计算图表中看涨信号的数量,然后在每个包含这些信号的烛台上方绘制看涨信号的数量。
我已经定义了模式、变量和信号。
只是需要帮助制作情节。我不知道如何让它正确地计算信号, 然后在烛台上显示该数字。
谢谢解答!!!
(更喜欢 V4,但任何答案都很好!)
//@version=4
study("", overlay = true, max_labels_count = 500)
bull_cond1 = crossover(ema(close,13), ema(close,20))
bull_cond2 = close > open
bull_cond3 = close > close[2]
bool global_bull_cond = bull_cond1 or bull_cond2 or bull_cond3
int bull_count = 0
if global_bull_cond
if bull_cond1
bull_count += 1
if bull_cond2
bull_count += 1
if bull_cond3
bull_count += 1
label.new(x = bar_index, y = high, style = label.style_label_down, size = size.tiny, color = color.lime, textcolor = color.black, text = tostring(bull_count))