简体   繁体   English

如何绘制一次形状并在满足另一个条件时停止绘制?

[英]How to plot a shape once and stop plotting while another condition is met?

This is the relevant script.这是相关的脚本。

lucidSARbullish=L_SAR < close
lucidSARbearish=L_SAR > close
bullishcondition=twohrRSI > 50 and price > lwma[1] and diplus > diminus and macd > signal and hist > 0 and oc == 1 and ruleState == 1 
         and adx > 20 and sqzmombull == true
bearishcondition=twohrRSI < 50 and price < lwma[1] and diplus < diminus and macd < signal and hist < 0 and oc != 1 and ruleState == -1 
         and adx > 20 and sqzmombear == true

As it stands, by default, the plot() function checks every single bar/period and plots if the condition is true.按照目前的情况,默认情况下, plot()函数会检查每个柱/周期,如果条件为真,则绘制图表。 I want to plot lucidSARbearish and lucidSARbullish separately as a yellow triangle (below for bullish, above for bearish), but it ends up overlapping with the shapes plotted by bullishcondition and bearishcondition .我想将lucidSARbearishlucidSARbullish分别绘制为一个黄色三角形(下方为看涨,上方为看跌),但它最终与bullishconditionbearishcondition绘制的形状重叠。

How can I make it so that when lucidSARbearish and lucidSARbullish are true, it plots the yellow triangle just once, and doesn't plot again while bullishcondition and/or bearishcondition are true?我怎样才能做到当lucidSARbearishlucidSARbullish为真时,它只绘制一次黄色三角形,并且在bullishcondition和/或bearishcondition为真时不再绘制?

Thanks in advance.提前致谢。

I'm dumb, but I still don't exactly know how to have it only plot once then wait for the bullish/bearish conditions to go true to false to plot again.我很笨,但我仍然不完全知道如何让它只绘制一次,然后等待看涨/看跌条件变为真到假再绘制。 While not necessary, I think it'll be more useful that way.虽然不是必需的,但我认为这样会更有用。

lucidSARbullish=L_SAR < close and bullishcondition==false
lucidSARbearish=L_SAR > close and bearishconditon==false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM