#### Pine Script: All three indicators have to confirm trend

1 个回复

``````//@version=5
indicator("My Script", overlay=true)

var bool    a = na // indicator 1
var bool    b = na // indicator 2
var bool    c = na // indicator 3
var bool    m = na // melting indicator

m := a and b and c and (not a[1] or not a[2]) and (not b[1] or not b[2]) and (not c[1] or not c[2])

plot(na)
``````

``````//@version=5
indicator("My Script", overlay=true)

var bool    a = na // indicator 1
var bool    b = na // indicator 2
var bool    c = na // indicator 3
var bool    m = na // melting indicator

f_check(bool _x) => _x and (not _x[1] or not _x[2])

m := f_check(a) and f_check(b) and f_check(c)

plot(na)
``````

``````//@version=5
indicator("My Script", overlay=true)

var bool    a           = na // indicator 1
var bool    b           = na // indicator 2
var bool    c           = na // indicator 3
var bool    m           = na // melting indicator
var bool    a_triggered = false
var bool    b_triggered = false
var bool    c_triggered = false

// once triggered, keep triggered until reset
a_triggered := not a or a_triggered[1]
b_triggered := not b or b_triggered[1]
c_triggered := not c or c_triggered[1]

// melting indicator will ony be able to be true when conditions are met for a, b, c AND if all triggers have fired since last reset
m := a and b and c and a_triggered and b_triggered and c_triggered

// melting indicator is true?
if m
// reset triggers
a_triggered := false
b_triggered := false
c_triggered := false

plot(na)
``````
1 Pine Script 中的线条趋势颜色

2 Pine Script 中的 RSI 乒乓指标

5 使用Python和Pandas从指标生成趋势

6 我如何将Pinescript设置为仅比原始指标高5％买入一次

7 关于 pinescript 中指标的手动缩放

8 Pinescript，转换v2-v4图表偏移问题-MTF指标