对于MACD,我想找到交叉低于0且MACD线高于信号线的时间

时间:2020-06-04 23:53:20

标签: pine-script

[macdLine, signalLine, histLine] = macd(close, 12, 26, 9)
MA = ema(close, 200)
a = 0.0
if crossover(macdLine, signalLine)
   a := valuewhen(crossover(MA, close), close, 1)

plotarrow(a)

我想做

If crossover(macdLine, signalLine) and crossunder(macdLine, 0)

但这不起作用。

编辑

我想检查市场是否在ema 200以上,MACD交叉信号线以及MACD是否在零以下。

strategy("MACD Cross over Strategy", overlay=true)

[macdLine, signalLine, histLine] = macd(close, 12, 26, 9)

MA = ema(close, 200)

a = 0.0
if crossover(macdLine, signalLine) and (macdLine < 0)
    a := valuewhen(crossover(MA, close), close, 1)

plotarrow(a)

if a
    strategy.entry("Buy", strategy.long, 1, comment="MacdLE")

strategy.exit("sell", "Buy",  loss=5, profit=15)

0 个答案:

没有答案