【发布时间】:2021-10-03 16:15:58
【问题描述】:
我正在尝试用我的脚本实现一些目标...
- 如果前一个信号是“卖出”,我只想打印一个“买入”信号(反之亦然)
- 如果它小于之前的“卖出”信号,我只想打印一个“买入”信号。 (反之亦然)
我整天都在努力寻找解决这个问题的方法。 我不明白如何使用“valuewhen”或“barssince”来实现这一点。
我是脚本新手。
//Long
emalong = out1 > out2
macdlong = macd > signal and ((macd[1] < signal[1]) or (macd[2] <
signal[2]))
psarlong = psar < close and ((psar[1] > close[1]) or (psar[2] >
close[2]))
//Short
emashort = out1 < out2
macdshort = macd < signal and ((macd[1] > signal[1]) or (macd[2]
> signal[2]))
psarshort = psar > close and ((psar[1] < close[1]) or (psar[2] <
close[2]))
//Collect
longentry = emalong and macdlong and psarlong
shortentry = emashort and macdshort and psarshort
//Plot
plotshape(longentry, style=shape.circle, color=#26a69a, text="⬆",
textcolor=#ffffff, location=location.belowbar,
size=size.tiny)
plotshape(shortentry, style=shape.circle, color=#ef5350,
text="⬇", textcolor=#ffffff, location=location.abovebar,
size=size.tiny)
【问题讨论】:
标签: pine-script indicator