我如何用布尔表达式解决这个问题

时间:2021-02-26 14:57:17

标签: pine-script indicator

我正在编写一个脚本,如果满足多个条件,它将触发交易信号。我为 Damiani Volatmeter 创建了一个布尔表达式,这样我就可以打开和关闭它并查看它的工作情况或它的糟糕程度,但是每当我关闭它时,唯一会发生的事情就是它在图表上的绘图,但计算即使关闭,仍然依赖它。我想要做的是,每当我关闭 Damiani 伏特计时,其他条件都应该计算而不考虑它。就像在下面的例子中一样,我只希望 base_cross_Long 的条件应该是我获得交易信号所需的唯一条件,因为 Damiani Volatmeter 被关闭,当 Damiani Volatmeter 被打开时,它应该需要base_cross_Long 和 DV_Long 条件考虑在内。

//------------Baseline--------------//
base_cross_Long = cross(price, baseline)
base_cross_Short = cross(baseline, price)
///////


//---------Damiani Volatmeter-------//
dummydv = input(false, title="Damiani Volatmeter")
usevolmode = true //input(true, title = "use volume Mode")
vis_atr = input(13)
vis_std = input(20)
sed_atr = input(40)
sed_std = input(100)
threshold_level = input(1.4)
lag_supressor = input(true)

atrv(len)=>rma(volume,len)
//DV(13,20,40,100,1.4,true)
DV(vis_atr,vis_std,sed_atr,sed_std, threshold_level,lag_supressor)=>
    vol = 0
    lag_s_K = 0.5
    s1=nz(vol[1], 0)
    s3=nz(vol[3], 0)

vol = lag_supressor ? atr(vis_atr) / atr(sed_atr) + lag_s_K*(s1-s3) : atr(vis_atr) / atr(sed_atr)
anti_thres = stdev(close, vis_std) / stdev(close, sed_std)
t = threshold_level - anti_thres
vol_m = vol > t ? -1 : 0.03

DV_vol=dummydv ? vol : na
DV_t=dummydv ? t : na
DV_mvol=dummydv ? vol_m : na

plot(DV_vol, title="V", color=color.purple)
plot(DV_t, title="A", color=color.silver)
plot(DV_mvol, title="T", color=color.maroon)

DV_Long = DV_vol > DV_t
DV_Short = DV_vol > DV_t

BuyLong = base_cross_Long and DV_Long
SellShort = base_cross_Short and DV_Short

0 个答案:

没有答案
相关问题